brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.1 KiB · 438523f Raw
141 lines · plain
1include "llvm/Target/Target.td"2 3def TestTargetInstrInfo : InstrInfo;4 5def TestTarget : Target {6  let InstructionSet = TestTargetInstrInfo;7}8 9class Indexes<int N> {10  list<int> all = [0,   1,  2,  3,  4,  5,  6 , 7,11                   8,   9, 10, 11, 12, 13, 14, 15,12                   16, 17, 18, 19, 20, 21, 22, 23,13                   24, 25, 26, 27, 28, 29, 30, 31];14  list<int> slice =15    !foldl([]<int>, all, acc, cur,16           !listconcat(acc, !if(!lt(cur, N), [cur], [])));17}18 19#ifdef USE_NAMESPACE20  let Namespace = "TestNamespace" in {21#endif22foreach Index = 0...31 in {23  def sub#Index : SubRegIndex<32, !shl(Index, 5)>;24}25 26foreach Size = {2,4,8,16} in {27  foreach Index = Indexes<!add(33, !mul(Size, -1))>.slice in {28    def !foldl("", Indexes<Size>.slice, acc, cur,29               !strconcat(acc#!if(!eq(acc,""),"","_"), "sub"#!add(cur, Index))) :30      SubRegIndex<!mul(Size, 32), !shl(Index, 5)> {31      let CoveringSubRegIndices =32        !foldl([]<SubRegIndex>, Indexes<Size>.slice, acc, cur,33               !listconcat(acc, [!cast<SubRegIndex>(sub#!add(cur, Index))]));34    }35  }36}37 38foreach Index = 0...255 in {39  def R#Index : Register <"r"#Index>;40}41#ifdef USE_NAMESPACE42}43#endif44 45def GPR32 : RegisterClass<"TestTarget", [i32], 32,46                          (add (sequence "R%u", 0, 255))>;47 48def GPR64 : RegisterTuples<[sub0, sub1],49                           [(decimate (shl GPR32, 0), 1),50                            (decimate (shl GPR32, 1), 1)51                           ]>;52 53def GPR128 : RegisterTuples<[sub0, sub1, sub2, sub3],54                            [55                             (decimate (shl GPR32, 0), 1),56                             (decimate (shl GPR32, 1), 1),57                             (decimate (shl GPR32, 2), 1),58                             (decimate (shl GPR32, 3), 1)59                            ]>;60 61def GPR256 : RegisterTuples<[sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7],62                             [63                              (decimate (shl GPR32, 0), 1),64                              (decimate (shl GPR32, 1), 1),65                              (decimate (shl GPR32, 2), 1),66                              (decimate (shl GPR32, 3), 1),67                              (decimate (shl GPR32, 4), 1),68                              (decimate (shl GPR32, 5), 1),69                              (decimate (shl GPR32, 6), 1),70                              (decimate (shl GPR32, 7), 1)71                             ]>;72 73def GPR512 : RegisterTuples<[sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7,74                             sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15],75                             [76                              (decimate (shl GPR32, 0), 1),77                              (decimate (shl GPR32, 1), 1),78                              (decimate (shl GPR32, 2), 1),79                              (decimate (shl GPR32, 3), 1),80                              (decimate (shl GPR32, 4), 1),81                              (decimate (shl GPR32, 5), 1),82                              (decimate (shl GPR32, 6), 1),83                              (decimate (shl GPR32, 7), 1),84                              (decimate (shl GPR32, 8), 1),85                              (decimate (shl GPR32, 9), 1),86                              (decimate (shl GPR32, 10), 1),87                              (decimate (shl GPR32, 11), 1),88                              (decimate (shl GPR32, 12), 1),89                              (decimate (shl GPR32, 13), 1),90                              (decimate (shl GPR32, 14), 1),91                              (decimate (shl GPR32, 15), 1)92                             ]>;93 94def GPR1024 : RegisterTuples<[sub0, sub1, sub2, sub3, sub4, sub5, sub6, sub7,95                              sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15,96                              sub16, sub17, sub18, sub19, sub20, sub21, sub22, sub23,97                              sub24, sub25, sub26, sub27, sub28, sub29, sub30, sub31],98                             [99                              (decimate (shl GPR32, 0), 1),100                              (decimate (shl GPR32, 1), 1),101                              (decimate (shl GPR32, 2), 1),102                              (decimate (shl GPR32, 3), 1),103                              (decimate (shl GPR32, 4), 1),104                              (decimate (shl GPR32, 5), 1),105                              (decimate (shl GPR32, 6), 1),106                              (decimate (shl GPR32, 7), 1),107                              (decimate (shl GPR32, 8), 1),108                              (decimate (shl GPR32, 9), 1),109                              (decimate (shl GPR32, 10), 1),110                              (decimate (shl GPR32, 11), 1),111                              (decimate (shl GPR32, 12), 1),112                              (decimate (shl GPR32, 13), 1),113                              (decimate (shl GPR32, 14), 1),114                              (decimate (shl GPR32, 15), 1),115                              (decimate (shl GPR32, 16), 1),116                              (decimate (shl GPR32, 17), 1),117                              (decimate (shl GPR32, 18), 1),118                              (decimate (shl GPR32, 19), 1),119                              (decimate (shl GPR32, 20), 1),120                              (decimate (shl GPR32, 21), 1),121                              (decimate (shl GPR32, 22), 1),122                              (decimate (shl GPR32, 23), 1),123                              (decimate (shl GPR32, 24), 1),124                              (decimate (shl GPR32, 25), 1),125                              (decimate (shl GPR32, 26), 1),126                              (decimate (shl GPR32, 27), 1),127                              (decimate (shl GPR32, 28), 1),128                              (decimate (shl GPR32, 29), 1),129                              (decimate (shl GPR32, 30), 1),130                              (decimate (shl GPR32, 31), 1)131                             ]>;132 133#ifdef USE_NAMESPACE134  let Namespace = "TestNamespace" in {135#endif136def GPR_64 : RegisterClass<"", [v2i32], 64, (add GPR64)>;137def GPR_1024 : RegisterClass<"", [v32i32], 1024, (add GPR1024)>;138#ifdef USE_NAMESPACE139}140#endif141