blob: 94e24810d653f6e2d8ebb4f66f3a44db5c308c14 [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"
12
13#if defined(__arm__)
14# define ANDROID_ARM_CODEGEN 1
15#else
16# define ANDROID_ARM_CODEGEN 0
17#endif
18
19#define ASSEMBLY_SCRATCH_SIZE 2048
20
21using namespace android;
22
23class ScanlineAssembly : public Assembly {
24 AssemblyKey<needs_t> mKey;
25public:
26 ScanlineAssembly(needs_t needs, size_t size)
27 : Assembly(size), mKey(needs) { }
28 const AssemblyKey<needs_t>& key() const { return mKey; }
29};
30
31static void ggl_test_codegen(uint32_t n, uint32_t p, uint32_t t0, uint32_t t1)
32{
33#if ANDROID_ARM_CODEGEN
34 GGLContext* c;
35 gglInit(&c);
36 needs_t needs;
37 needs.n = n;
38 needs.p = p;
39 needs.t[0] = t0;
40 needs.t[1] = t1;
41 sp<ScanlineAssembly> a(new ScanlineAssembly(needs, ASSEMBLY_SCRATCH_SIZE));
42 GGLAssembler assembler( new ARMAssembler(a) );
43 int err = assembler.scanline(needs, (context_t*)c);
44 if (err != 0) {
45 printf("error %08x (%s)\n", err, strerror(-err));
46 }
47 gglUninit(c);
48#else
49 printf("This test runs only on ARM\n");
50#endif
51}
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080052
53int main(int argc, char** argv)
54{
55 if (argc != 2) {
56 printf("usage: %s 00000117:03454504_00001501_00000000\n", argv[0]);
57 return 0;
58 }
59 uint32_t n;
60 uint32_t p;
61 uint32_t t0;
62 uint32_t t1;
63 sscanf(argv[1], "%08x:%08x_%08x_%08x", &p, &n, &t0, &t1);
64 ggl_test_codegen(n, p, t0, t1);
65 return 0;
66}