diff options
author | Dan Gohman <sunfish@google.com> | 2014-02-12 17:50:47 -0800 |
---|---|---|
committer | Dan Gohman <sunfish@google.com> | 2014-02-12 18:16:37 -0800 |
commit | 59147c7295d0698b440f455e9080acc67aa80bff (patch) | |
tree | d96a3c8419f14bc3bdc4b97f625238c9142e9f29 /test | |
parent | 08cdac187ad3a109d5e68c771ca2b2d2e23d9e3f (diff) |
Create a test directory for basic JS Codegen
Diffstat (limited to 'test')
-rw-r--r-- | test/CodeGen/JS/basics.ll | 27 | ||||
-rw-r--r-- | test/CodeGen/JS/getelementptr.ll | 12 | ||||
-rw-r--r-- | test/CodeGen/JS/globals.ll | 42 | ||||
-rw-r--r-- | test/CodeGen/JS/lit.local.cfg | 6 |
4 files changed, 87 insertions, 0 deletions
diff --git a/test/CodeGen/JS/basics.ll b/test/CodeGen/JS/basics.ll new file mode 100644 index 0000000000..8c84b6b37b --- /dev/null +++ b/test/CodeGen/JS/basics.ll @@ -0,0 +1,27 @@ +; RUN: llc < %s -march=js -o - | FileCheck %s + +; CHECK: function _simple_integer_math( +; CHECK: [[VAL_A:\$[a-z]+]] = [[VAL_A]]|0; +; CHECK: [[VAL_B:\$[a-z]+]] = [[VAL_B]]|0; +; CHECK: [[VAL_C:\$[a-z]+]] = (([[VAL_A]]) + ([[VAL_B]]))|0; +; CHECK: [[VAL_D:\$[a-z]+]] = ([[VAL_C]]*20)|0; +; CHECK: [[VAL_E:\$[a-z]+]] = (([[VAL_D]]|0) / ([[VAL_A]]|0))&-1; +; CHECK: [[VAL_F:\$[a-z]+]] = (([[VAL_E]]) - 3)|0; +; CHECK: return [[VAL_F]]|0; +define i32 @simple_integer_math(i32 %a, i32 %b) nounwind { + %c = add i32 %a, %b + %d = mul i32 %c, 20 + %e = sdiv i32 %d, %a + %f = sub i32 %e, 3 + ret i32 %f +} + +; CHECK: function _fneg( +; CHECK: [[VAL_D:\$[a-z]+]] = +[[VAL_D]] +; CHECK: [[VAL_F:\$[a-z]+]] = +0 +; CHECK: [[VAL_F]] = -[[VAL_D]] +; CHECK: return +[[VAL_F]]; +define double @fneg(double %d) nounwind { + %f = fsub double -0.0, %d + ret double %f +} diff --git a/test/CodeGen/JS/getelementptr.ll b/test/CodeGen/JS/getelementptr.ll new file mode 100644 index 0000000000..2291909778 --- /dev/null +++ b/test/CodeGen/JS/getelementptr.ll @@ -0,0 +1,12 @@ +; RUN: opt -S < %s -expand-getelementptr | llc -march=js | FileCheck %s + +; Test simple getelementptr codegen. + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" + +; CHECK: function _getelementptr([[VAL_P:\$[a-z_]+]]) { +; CHECK: [[GEP:\$[a-z_]+]] = (([[GEPINT:\$[a-z_]+]]) + 588)|0; +define i32* @getelementptr([10 x [12 x i32] ]* %p) { + %t = getelementptr [10 x [12 x i32]]* %p, i32 1, i32 2, i32 3 + ret i32* %t +} diff --git a/test/CodeGen/JS/globals.ll b/test/CodeGen/JS/globals.ll new file mode 100644 index 0000000000..3a8a3a692c --- /dev/null +++ b/test/CodeGen/JS/globals.ll @@ -0,0 +1,42 @@ +; RUN: llc -march=js %s -o - | FileCheck %s + +; Test simple global variable codegen. + +; CHECK: function _loads() { +; CHECK: [[VAR_t:\$[a-z]+]] = HEAP32[2]|0; +; CHECK: [[VAR_s:\$[a-z]+]] = +HEAPF64[2]; +; CHECK: [[VAR_u:\$[a-z]+]] = HEAP8[24]|0; +; CHECK: [[VAR_a:\$[a-z]+]] = ~~(([[VAR_s:\$[a-z]+]]))>>>0; +; CHECK: [[VAR_b:\$[a-z]+]] = [[VAR_u:\$[a-z]+]] << 24 >> 24; +; CHECK: [[VAR_c:\$[a-z]+]] = (([[VAR_t:\$[a-z]+]]) + ([[VAR_a:\$[a-z]+]]))|0; +; CHECK: [[VAR_d:\$[a-z]+]] = (([[VAR_c:\$[a-z]+]]) + ([[VAR_b:\$[a-z]+]]))|0; +; CHECK: return [[VAR_d:\$[a-z]+]]|0; +define i32 @loads() { + %t = load i32* @A + %s = load double* @B + %u = load i8* @C + %a = fptoui double %s to i32 + %b = sext i8 %u to i32 + %c = add i32 %t, %a + %d = add i32 %c, %b + ret i32 %d +} + +; CHECK: function _stores([[VAR_m:\$[a-z]+]],[[VAR_n:\$[a-z]+]],[[VAR_o:\$[a-z]+]]) { +; CHECK: [[VAR_m:\$[a-z]+]] = [[VAR_m:\$[a-z]+]]|0; +; CHECK: [[VAR_n:\$[a-z]+]] = [[VAR_n:\$[a-z]+]]|0; +; CHECK: [[VAR_o:\$[a-z]+]] = +[[VAR_o:\$[a-z]+]]; +; CHECK: HEAP32[2] = [[VAR_n:\$[a-z]+]]; +; CHECK: HEAPF64[2] = [[VAR_o:\$[a-z]+]]; +; CHECK: HEAP8[24] = [[VAR_m:\$[a-z]+]]; +define void @stores(i8 %m, i32 %n, double %o) { + store i32 %n, i32* @A + store double %o, double* @B + store i8 %m, i8* @C + ret void +} + +; CHECK: allocate([133,26,0,0,0,0,0,0,205,204,204,204,204,76,55,64,2,0,0,0,0,0,0,0], "i8", ALLOC_NONE, Runtime.GLOBAL_BASE); +@A = global i32 6789 +@B = global double 23.3 +@C = global i8 2 diff --git a/test/CodeGen/JS/lit.local.cfg b/test/CodeGen/JS/lit.local.cfg new file mode 100644 index 0000000000..ee9b61f930 --- /dev/null +++ b/test/CodeGen/JS/lit.local.cfg @@ -0,0 +1,6 @@ +config.suffixes = ['.ll', '.c', '.cpp'] + +targets = set(config.root.targets_to_build.split()) +if not 'JSBackend' in targets: + config.unsupported = True + |