diff options
author | Stephen Hines <srhines@google.com> | 2014-12-01 14:51:49 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2014-12-02 16:08:10 -0800 |
commit | 37ed9c199ca639565f6ce88105f9e39e898d82d0 (patch) | |
tree | 8fb36d3910e3ee4c4e1b7422f4f017108efc52f5 /test/TableGen | |
parent | d2327b22152ced7bc46dc629fc908959e8a52d03 (diff) | |
download | external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.gz external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.tar.bz2 external_llvm-37ed9c199ca639565f6ce88105f9e39e898d82d0.zip |
Update aosp/master LLVM for rebase to r222494.
Change-Id: Ic787f5e0124df789bd26f3f24680f45e678eef2d
Diffstat (limited to 'test/TableGen')
-rw-r--r-- | test/TableGen/BitOffsetDecoder.td | 74 | ||||
-rw-r--r-- | test/TableGen/BitsInit.td | 85 | ||||
-rw-r--r-- | test/TableGen/ClassInstanceValue.td | 19 | ||||
-rw-r--r-- | test/TableGen/ForeachList.td | 1 | ||||
-rw-r--r-- | test/TableGen/ForeachLoop.td | 1 | ||||
-rw-r--r-- | test/TableGen/NestedForeach.td | 1 | ||||
-rw-r--r-- | test/TableGen/SiblingForeach.td | 1 | ||||
-rw-r--r-- | test/TableGen/if.td | 2 | ||||
-rw-r--r-- | test/TableGen/ifbit.td | 2 | ||||
-rw-r--r-- | test/TableGen/intrinsic-long-name.td | 32 | ||||
-rw-r--r-- | test/TableGen/intrinsic-varargs.td | 2 | ||||
-rw-r--r-- | test/TableGen/list-element-bitref.td | 2 | ||||
-rw-r--r-- | test/TableGen/math.td | 18 |
13 files changed, 233 insertions, 7 deletions
diff --git a/test/TableGen/BitOffsetDecoder.td b/test/TableGen/BitOffsetDecoder.td new file mode 100644 index 0000000000..ec0ceeee8a --- /dev/null +++ b/test/TableGen/BitOffsetDecoder.td @@ -0,0 +1,74 @@ +// RUN: llvm-tblgen -gen-disassembler -I %p/../../include %s | FileCheck %s + +include "llvm/Target/Target.td" + +def archInstrInfo : InstrInfo { } + +def arch : Target { + let InstructionSet = archInstrInfo; +} + +def Myi32 : Operand<i32> { + let DecoderMethod = "DecodeMyi32"; +} + + +let OutOperandList = (outs), Size = 2 in { + +def foo : Instruction { + let InOperandList = (ins i32imm:$factor); + field bits<16> Inst; + bits<32> factor; + let Inst{7-0} = 0xAA; + let Inst{14-8} = factor{6-0}; // no offset + let AsmString = "foo $factor"; + field bits<16> SoftFail = 0; + } + +def bar : Instruction { + let InOperandList = (ins i32imm:$factor); + field bits<16> Inst; + bits<32> factor; + let Inst{7-0} = 0xBB; + let Inst{15-8} = factor{10-3}; // offset by 3 + let AsmString = "bar $factor"; + field bits<16> SoftFail = 0; + } + +def biz : Instruction { + let InOperandList = (ins i32imm:$factor); + field bits<16> Inst; + bits<32> factor; + let Inst{7-0} = 0xCC; + let Inst{11-8,15-12} = factor{10-3}; // offset by 3, multipart + let AsmString = "biz $factor"; + field bits<16> SoftFail = 0; + } + +def baz : Instruction { + let InOperandList = (ins Myi32:$factor); + field bits<16> Inst; + bits<32> factor; + let Inst{7-0} = 0xDD; + let Inst{15-8} = factor{11-4}; // offset by 4 + custom decode + let AsmString = "baz $factor"; + field bits<16> SoftFail = 0; + } + +def bum : Instruction { + let InOperandList = (ins i32imm:$factor); + field bits<16> Inst; + bits<32> factor; + let Inst{7-0} = 0xEE; + let Inst{15-8} = !srl(factor,5); + let AsmString = "bum $factor"; + field bits<16> SoftFail = 0; + } +} + + +// CHECK: tmp = fieldFromInstruction(insn, 8, 7); +// CHECK: tmp = fieldFromInstruction(insn, 8, 8) << 3; +// CHECK: tmp |= fieldFromInstruction(insn, 8, 4) << 7; +// CHECK: tmp |= fieldFromInstruction(insn, 12, 4) << 3; +// CHECK: tmp = fieldFromInstruction(insn, 8, 8) << 4; diff --git a/test/TableGen/BitsInit.td b/test/TableGen/BitsInit.td new file mode 100644 index 0000000000..6aac3e41c6 --- /dev/null +++ b/test/TableGen/BitsInit.td @@ -0,0 +1,85 @@ + +// RUN: not llvm-tblgen %s 2>&1 > %t +// RUN: FileCheck %s < %t + +def a { + bits<2> opc = { 0, 1 }; + bits<2> opc2 = { 1, 0 }; + bits<1> opc3 = { 1 }; + bits<2> a = { opc, opc2 }; // error! + bits<2> b = { opc{0}, opc2{0} }; + bits<2> c = { opc{1}, opc2{1} }; + bits<2> c = { opc3{0}, opc3 }; +} + +// CHECK: def a { +// CHECK: bits<2> opc = { 0, 1 }; +// CHECK: bits<2> opc2 = { 1, 0 }; +// CHECK: bits<1> opc3 = { 1 }; +// CHECK: bits<2> a; +// CHECK: bits<2> b = { 1, 0 }; +// CHECK: bits<2> c = { 1, 1 }; +// CHECK: } + +def { + bits<2> B1 = 0b011; // bitfield is too small, reject + bits<3> B2 = 0b011; // ok + + bits<2> C1 = 0b111; // bitfield is too small, reject + bits<3> C2 = 0b111; // ok + + bits<2> D1 = { 0, 0 }; // ok + bits<2> D2 = { 0b00 }; // ok + bits<3> D3 = { 0, 0 }; // type mismatch. RHS doesn't have enough bits + bits<3> D4 = { 0b00 }; // type mismatch. RHS doesn't have enough bits + bits<1> D5 = { 0 }; // ok + bits<1> D6 = { 1 }; // ok + bits<1> D7 = { 3 }; // type mismatch. LHS doesn't have enough bits + bits<2> D8 = { 0 }; // type mismatch. RHS doesn't have enough bits + + bits<8> E; + let E{7-0} = {0,0,1,?,?,?,?,?}; + let E{3-0} = 0b0010; + + bits<8> F1 = { 0, 1, 0b1001, 0, 0b0 }; // ok + bits<7> F2 = { 0, 1, 0b1001, 0, 0b0 }; // LHS doesn't have enough bits + bits<9> F3 = { 0, 1, 0b1001, 0, 0b0 }; // RHS doesn't have enough bits + + bits<8> G1 = { 0, { 1, 0b1001, 0 }, 0b0 }; // ok + bits<8> G2 = { 0, { 1, 0b1001 }, 0, 0b0 }; // ok + bits<8> G3 = { 0, 1, { 0b1001 }, 0, 0b0 }; // ok + + bits<16> H; + let H{15-0} = { { 0b11001100 }, 0b00110011 }; + bits<16> I = { G1, G2 }; + + // Make sure we can initialise ints with bits<> values. + int J = H; + int K = { 0, 1 }; +} + +// CHECK: def {{.*}} { +// CHECK: bits<2> B1; +// CHECK: bits<3> B2 = { 0, 1, 1 }; +// CHECK: bits<2> C1; +// CHECK: bits<3> C2 = { 1, 1, 1 }; +// CHECK: bits<2> D1 = { 0, 0 }; +// CHECK: bits<2> D2 = { 0, 0 }; +// CHECK: bits<3> D3; +// CHECK: bits<3> D4; +// CHECK: bits<1> D5 = { 0 }; +// CHECK: bits<1> D6 = { 1 }; +// CHECK: bits<1> D7 = { ? }; +// CHECK: bits<2> D8; +// CHECK: bits<8> E = { 0, 0, 1, ?, 0, 0, 1, 0 }; +// CHECK: bits<8> F1 = { 0, 1, 1, 0, 0, 1, 0, 0 }; +// CHECK: bits<7> F2; +// CHECK: bits<9> F3; +// CHECK: bits<8> G1 = { 0, 1, 1, 0, 0, 1, 0, 0 }; +// CHECK: bits<8> G2 = { 0, 1, 1, 0, 0, 1, 0, 0 }; +// CHECK: bits<8> G3 = { 0, 1, 1, 0, 0, 1, 0, 0 }; +// CHECK: bits<16> H = { 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1 }; +// CHECK: bits<16> I = { 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0 }; +// CHECK: int J = 52275; +// CHECK: int K = 1; +// CHECK: } diff --git a/test/TableGen/ClassInstanceValue.td b/test/TableGen/ClassInstanceValue.td new file mode 100644 index 0000000000..b6c4c93cb0 --- /dev/null +++ b/test/TableGen/ClassInstanceValue.td @@ -0,0 +1,19 @@ +// RUN: llvm-tblgen %s | FileCheck %s +// XFAIL: vg_leak + +class Struct<int i> { + int I = !shl(i, 1); + int J = !shl(I, 1); +} + +class Class<Struct s> { + int Class_J = s.J; +} + +multiclass MultiClass<int i> { + def Def : Class<Struct<i>>; +// CHECK: Class_J = 8 +// CHECK-NOT: Class_J = !shl(I, 1) +} + +defm Defm : MultiClass<2>; diff --git a/test/TableGen/ForeachList.td b/test/TableGen/ForeachList.td index 99b7e14c2d..9bc76e0f0c 100644 --- a/test/TableGen/ForeachList.td +++ b/test/TableGen/ForeachList.td @@ -1,5 +1,4 @@ // RUN: llvm-tblgen %s | FileCheck %s -// XFAIL: vg_leak class Register<string name, int idx> { string Name = name; diff --git a/test/TableGen/ForeachLoop.td b/test/TableGen/ForeachLoop.td index 25208fae22..ce8d44c752 100644 --- a/test/TableGen/ForeachLoop.td +++ b/test/TableGen/ForeachLoop.td @@ -1,5 +1,4 @@ // RUN: llvm-tblgen %s | FileCheck %s -// XFAIL: vg_leak class Register<string name, int idx> { string Name = name; diff --git a/test/TableGen/NestedForeach.td b/test/TableGen/NestedForeach.td index e8c16f720d..5b63175b19 100644 --- a/test/TableGen/NestedForeach.td +++ b/test/TableGen/NestedForeach.td @@ -1,5 +1,4 @@ // RUN: llvm-tblgen %s | FileCheck %s -// XFAIL: vg_leak class Droid<string series, int release, string model, int patchlevel> { string Series = series; diff --git a/test/TableGen/SiblingForeach.td b/test/TableGen/SiblingForeach.td index a11f6f87b4..e4c4704a5e 100644 --- a/test/TableGen/SiblingForeach.td +++ b/test/TableGen/SiblingForeach.td @@ -1,5 +1,4 @@ // RUN: llvm-tblgen %s | FileCheck %s -// XFAIL: vg_leak class Set<int i = 0, int j = 0, int k = 0> { int I = i; diff --git a/test/TableGen/if.td b/test/TableGen/if.td index 1d8d62329a..05a2d99285 100644 --- a/test/TableGen/if.td +++ b/test/TableGen/if.td @@ -3,7 +3,7 @@ // Support for an `!if' operator as part of a `let' statement. // CHECK: class C -// CHECK-NEXT: bits<16> n = { ?, ?, ?, ?, !if({ C:y{3} }, 1, !if({ C:y{2} }, { C:x{0} }, !if({ C:y{1} }, { C:x{1} }, !if({ C:y{0} }, { C:x{2} }, ?)))){0}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){1}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){0}, !if({ C:x{2} }, 2, 6){2}, !if({ C:x{2} }, 2, 6){1}, !if({ C:x{2} }, 2, 6){0}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){1}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){0}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){3}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){2}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){1}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){0} }; +// CHECK-NEXT: bits<16> n = { ?, ?, ?, ?, !if({ C:y{3} }, 1, !if({ C:y{2} }, { C:x{0} }, !if({ C:y{1} }, { C:x{1} }, !if({ C:y{0} }, { C:x{2} }, ?)))){0}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){1}, !if({ C:x{2} }, { C:y{3}, C:y{2} }, !if({ C:x{1} }, { C:y{2}, C:y{1} }, !if({ C:x{0} }, { C:y{1}, C:y{0} }, ?))){0}, !if({ C:x{2} }, { 0, 1, 0 }, { 1, 1, 0 }){2}, !if({ C:x{2} }, { 0, 1, 0 }, { 1, 1, 0 }){1}, !if({ C:x{2} }, { 0, 1, 0 }, { 1, 1, 0 }){0}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){1}, !if({ C:x{1} }, { C:y{3}, C:y{2} }, { 0, 1 }){0}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){3}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){2}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){1}, !if({ C:x{0} }, { C:y{3}, C:y{2}, C:y{1}, C:y{0} }, { C:z, C:y{2}, C:y{1}, C:y{0} }){0} }; class C<bits<3> x, bits<4> y, bit z> { bits<16> n; diff --git a/test/TableGen/ifbit.td b/test/TableGen/ifbit.td index 88f575e9ac..18797cac11 100644 --- a/test/TableGen/ifbit.td +++ b/test/TableGen/ifbit.td @@ -5,6 +5,8 @@ class A<bit b = 1> { int a = !if(b, 5, 6); + bit c = !if(b, 0, 1); + bits<1> d = !if(b, 0, 1); } def X : A<0>; diff --git a/test/TableGen/intrinsic-long-name.td b/test/TableGen/intrinsic-long-name.td new file mode 100644 index 0000000000..6b9ba018e3 --- /dev/null +++ b/test/TableGen/intrinsic-long-name.td @@ -0,0 +1,32 @@ +// RUN: llvm-tblgen -gen-intrinsic %s | FileCheck %s +// XFAIL: vg_leak + +class IntrinsicProperty; + +class ValueType<int size, int value> { + string Namespace = "MVT"; + int Size = size; + int Value = value; +} + +class LLVMType<ValueType vt> { + ValueType VT = vt; +} + +class Intrinsic<string name, list<LLVMType> param_types = []> { + string LLVMName = name; + bit isTarget = 0; + string TargetPrefix = ""; + list<LLVMType> RetTypes = []; + list<LLVMType> ParamTypes = param_types; + list<IntrinsicProperty> Properties = []; +} + +def iAny : ValueType<0, 254>; +def llvm_anyint_ty : LLVMType<iAny>; + +// Make sure we generate the long name without crashing +// CHECK: this_is_a_really_long_intrinsic_name_but_we_should_still_not_crash // llvm.this.is.a.really.long.intrinsic.name.but.we.should.still.not.crash +def int_foo : Intrinsic<"llvm.foo", [llvm_anyint_ty]>; +def int_this_is_a_really_long_intrinsic_name_but_we_should_still_not_crash : Intrinsic<"llvm.this.is.a.really.long.intrinsic.name.but.we.should.still.not.crash", [llvm_anyint_ty]>; + diff --git a/test/TableGen/intrinsic-varargs.td b/test/TableGen/intrinsic-varargs.td index 3e48f8da33..935a625038 100644 --- a/test/TableGen/intrinsic-varargs.td +++ b/test/TableGen/intrinsic-varargs.td @@ -26,5 +26,5 @@ class Intrinsic<string name, list<LLVMType> param_types = []> { def isVoid : ValueType<0, 56>; // Produces no value def llvm_vararg_ty : LLVMType<isVoid>; // this means vararg here -// CHECK: /* 0 */ 0, 27, 0, +// CHECK: /* 0 */ 0, 28, 0, def int_foo : Intrinsic<"llvm.foo", [llvm_vararg_ty]>; diff --git a/test/TableGen/list-element-bitref.td b/test/TableGen/list-element-bitref.td index 4622f28526..0f59b537fa 100644 --- a/test/TableGen/list-element-bitref.td +++ b/test/TableGen/list-element-bitref.td @@ -1,7 +1,7 @@ // RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak -class C<list<bits<8>> L> { +class C<list<bits<4>> L> { bits<2> V0 = L[0]{1-0}; bits<2> V1 = L[1]{3-2}; string V2 = !if(L[0]{0}, "Odd", "Even"); diff --git a/test/TableGen/math.td b/test/TableGen/math.td index 59d16ae908..d966346596 100644 --- a/test/TableGen/math.td +++ b/test/TableGen/math.td @@ -1,10 +1,26 @@ // RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak +def shifts { + bits<2> b = 0b10; + int i = 2; + int shifted_b = !shl(b, 2); + int shifted_i = !shl(i, 2); +} +// CHECK: def shifts +// CHECK: shifted_b = 8 +// CHECK: shifted_i = 8 + class Int<int value> { int Value = value; } +// CHECK: def v0 +// CHECK: Value = 0 + +// CHECK: def v1 +// CHECK: Value = 1 + def v1024 : Int<1024>; // CHECK: def v1024 // CHECK: Value = 1024 @@ -17,3 +33,5 @@ def v2048 : Int<!add(v1024.Value, v1024.Value)>; // CHECK: def v2048 // CHECK: Value = 2048 +def v0 : Int<!and(v1024.Value, v2048.Value)>; +def v1 : Int<!and(v1025.Value, 1)>; |