blob: e8a4f5e8c8b37aafe66eff47b77f69013c6a326e [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001#include <stdio.h>
2#include <stdint.h>
3
Jim Huang6090dac2010-08-10 02:03:29 +08004#include "private/pixelflinger/ggl_context.h"
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08005
Jim Huang6090dac2010-08-10 02:03:29 +08006#include "buffer.h"
7#include "scanline.h"
8
9#include "codeflinger/CodeCache.h"
10#include "codeflinger/GGLAssembler.h"
11#include "codeflinger/ARMAssembler.h"
Paul Lind2bc2b792012-02-01 10:54:19 -080012#include "codeflinger/MIPSAssembler.h"
Ashok Bhat658f89d2013-02-28 18:32:03 +000013#include "codeflinger/Aarch64Assembler.h"
Jim Huang6090dac2010-08-10 02:03:29 +080014
Ashok Bhat658f89d2013-02-28 18:32:03 +000015#if defined(__arm__) || defined(__mips__) || defined(__aarch64__)
Jim Huang6090dac2010-08-10 02:03:29 +080016# define ANDROID_ARM_CODEGEN 1
17#else
18# define ANDROID_ARM_CODEGEN 0
19#endif
20
Paul Lind2bc2b792012-02-01 10:54:19 -080021#if defined (__mips__)
22#define ASSEMBLY_SCRATCH_SIZE 4096
Ashok Bhat658f89d2013-02-28 18:32:03 +000023#elif defined(__aarch64__)
24#define ASSEMBLY_SCRATCH_SIZE 8192
Paul Lind2bc2b792012-02-01 10:54:19 -080025#else
Jim Huang6090dac2010-08-10 02:03:29 +080026#define ASSEMBLY_SCRATCH_SIZE 2048
Paul Lind2bc2b792012-02-01 10:54:19 -080027#endif
Jim Huang6090dac2010-08-10 02:03:29 +080028
29using namespace android;
30
31class ScanlineAssembly : public Assembly {
32 AssemblyKey<needs_t> mKey;
33public:
34 ScanlineAssembly(needs_t needs, size_t size)
35 : Assembly(size), mKey(needs) { }
36 const AssemblyKey<needs_t>& key() const { return mKey; }
37};
38
39static void ggl_test_codegen(uint32_t n, uint32_t p, uint32_t t0, uint32_t t1)
40{
41#if ANDROID_ARM_CODEGEN
42 GGLContext* c;
43 gglInit(&c);
44 needs_t needs;
45 needs.n = n;
46 needs.p = p;
47 needs.t[0] = t0;
48 needs.t[1] = t1;
49 sp<ScanlineAssembly> a(new ScanlineAssembly(needs, ASSEMBLY_SCRATCH_SIZE));
Paul Lind2bc2b792012-02-01 10:54:19 -080050
51#if defined(__arm__)
Jim Huang6090dac2010-08-10 02:03:29 +080052 GGLAssembler assembler( new ARMAssembler(a) );
Paul Lind2bc2b792012-02-01 10:54:19 -080053#endif
54
55#if defined(__mips__)
56 GGLAssembler assembler( new ArmToMipsAssembler(a) );
57#endif
58
Ashok Bhat658f89d2013-02-28 18:32:03 +000059#if defined(__aarch64__)
60 GGLAssembler assembler( new ArmToAarch64Assembler(a) );
61#endif
62
Jim Huang6090dac2010-08-10 02:03:29 +080063 int err = assembler.scanline(needs, (context_t*)c);
64 if (err != 0) {
65 printf("error %08x (%s)\n", err, strerror(-err));
66 }
67 gglUninit(c);
68#else
Ashok Bhat658f89d2013-02-28 18:32:03 +000069 printf("This test runs only on ARM, Aarch64 or MIPS\n");
Jim Huang6090dac2010-08-10 02:03:29 +080070#endif
71}
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080072
73int main(int argc, char** argv)
74{
75 if (argc != 2) {
76 printf("usage: %s 00000117:03454504_00001501_00000000\n", argv[0]);
77 return 0;
78 }
79 uint32_t n;
80 uint32_t p;
81 uint32_t t0;
82 uint32_t t1;
83 sscanf(argv[1], "%08x:%08x_%08x_%08x", &p, &n, &t0, &t1);
84 ggl_test_codegen(n, p, t0, t1);
85 return 0;
86}