The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdint.h> |
| 3 | |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 4 | #include "private/pixelflinger/ggl_context.h" |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 5 | |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 6 | #include "buffer.h" |
| 7 | #include "scanline.h" |
| 8 | |
| 9 | #include "codeflinger/CodeCache.h" |
| 10 | #include "codeflinger/GGLAssembler.h" |
| 11 | #include "codeflinger/ARMAssembler.h" |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 12 | #include "codeflinger/MIPSAssembler.h" |
Ashok Bhat | 658f89d | 2013-02-28 18:32:03 +0000 | [diff] [blame] | 13 | #include "codeflinger/Aarch64Assembler.h" |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 14 | |
Ashok Bhat | 658f89d | 2013-02-28 18:32:03 +0000 | [diff] [blame] | 15 | #if defined(__arm__) || defined(__mips__) || defined(__aarch64__) |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 16 | # define ANDROID_ARM_CODEGEN 1 |
| 17 | #else |
| 18 | # define ANDROID_ARM_CODEGEN 0 |
| 19 | #endif |
| 20 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 21 | #if defined (__mips__) |
| 22 | #define ASSEMBLY_SCRATCH_SIZE 4096 |
Ashok Bhat | 658f89d | 2013-02-28 18:32:03 +0000 | [diff] [blame] | 23 | #elif defined(__aarch64__) |
| 24 | #define ASSEMBLY_SCRATCH_SIZE 8192 |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 25 | #else |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 26 | #define ASSEMBLY_SCRATCH_SIZE 2048 |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 27 | #endif |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 28 | |
| 29 | using namespace android; |
| 30 | |
| 31 | class ScanlineAssembly : public Assembly { |
| 32 | AssemblyKey<needs_t> mKey; |
| 33 | public: |
| 34 | ScanlineAssembly(needs_t needs, size_t size) |
| 35 | : Assembly(size), mKey(needs) { } |
| 36 | const AssemblyKey<needs_t>& key() const { return mKey; } |
| 37 | }; |
| 38 | |
| 39 | static 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 Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 50 | |
| 51 | #if defined(__arm__) |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 52 | GGLAssembler assembler( new ARMAssembler(a) ); |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 53 | #endif |
| 54 | |
| 55 | #if defined(__mips__) |
| 56 | GGLAssembler assembler( new ArmToMipsAssembler(a) ); |
| 57 | #endif |
| 58 | |
Ashok Bhat | 658f89d | 2013-02-28 18:32:03 +0000 | [diff] [blame] | 59 | #if defined(__aarch64__) |
| 60 | GGLAssembler assembler( new ArmToAarch64Assembler(a) ); |
| 61 | #endif |
| 62 | |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 63 | 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 Bhat | 658f89d | 2013-02-28 18:32:03 +0000 | [diff] [blame] | 69 | printf("This test runs only on ARM, Aarch64 or MIPS\n"); |
Jim Huang | 6090dac | 2010-08-10 02:03:29 +0800 | [diff] [blame] | 70 | #endif |
| 71 | } |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 72 | |
| 73 | int 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 | } |