Chris Lattner | ee6b5f6 | 2003-07-29 23:07:13 +0000 | [diff] [blame] | 1 | //===- Target.td - Target Independent TableGen interface --------*- C++ -*-===// |
| 2 | // |
| 3 | // This file defines the target-independent interfaces which should be |
| 4 | // implemented by each target which is using a TableGen based code generator. |
| 5 | // |
Misha Brukman | 01c1638 | 2003-05-29 18:48:17 +0000 | [diff] [blame] | 6 | //===----------------------------------------------------------------------===// |
| 7 | |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 8 | |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | // |
Chris Lattner | b3aa319 | 2003-07-28 04:24:59 +0000 | [diff] [blame] | 11 | // Value types - These values correspond to the register types defined in the |
Chris Lattner | 84c40c1 | 2003-07-29 23:02:49 +0000 | [diff] [blame] | 12 | // ValueTypes.h file. |
Chris Lattner | 0ad1361 | 2003-07-30 22:16:41 +0000 | [diff] [blame] | 13 | // |
Chris Lattner | de04dd7 | 2003-08-01 05:18:03 +0000 | [diff] [blame] | 14 | class ValueType<int size> { string Namespace = "MVT"; int Size = size; } |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 15 | |
Chris Lattner | de04dd7 | 2003-08-01 05:18:03 +0000 | [diff] [blame] | 16 | def i1 : ValueType<1>; // One bit boolean value |
| 17 | def i8 : ValueType<8>; // 8-bit integer value |
| 18 | def i16 : ValueType<16>; // 16-bit integer value |
| 19 | def i32 : ValueType<32>; // 32-bit integer value |
| 20 | def i64 : ValueType<64>; // 64-bit integer value |
| 21 | def i128 : ValueType<128>; // 128-bit integer value |
| 22 | def f32 : ValueType<32>; // 32-bit floating point value |
| 23 | def f64 : ValueType<64>; // 64-bit floating point value |
| 24 | def f80 : ValueType<80>; // 80-bit floating point value |
| 25 | def f128 : ValueType<128>; // 128-bit floating point value |
Chris Lattner | b3aa319 | 2003-07-28 04:24:59 +0000 | [diff] [blame] | 26 | |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 27 | |
| 28 | //===----------------------------------------------------------------------===// |
| 29 | // Register file description - These classes are used to fill in the target |
| 30 | // description classes in llvm/Target/MRegisterInfo.h |
| 31 | |
| 32 | |
| 33 | // Register - You should define one instance of this class for each register in |
| 34 | // the target machine. |
| 35 | // |
Misha Brukman | 01c1638 | 2003-05-29 18:48:17 +0000 | [diff] [blame] | 36 | class Register { |
| 37 | string Namespace = ""; |
Chris Lattner | 76bf868 | 2003-08-03 22:12:37 +0000 | [diff] [blame] | 38 | string Name = ""; |
| 39 | } |
| 40 | |
| 41 | // NamedReg - If the name for the 'def' of the register should not become the |
| 42 | // "name" of the register, you can use this to specify a custom name instead. |
| 43 | // |
| 44 | class NamedReg<string n> : Register { |
Chris Lattner | 60e81db | 2003-08-04 04:58:12 +0000 | [diff] [blame] | 45 | let Name = n; |
Misha Brukman | 01c1638 | 2003-05-29 18:48:17 +0000 | [diff] [blame] | 46 | } |
| 47 | |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 48 | // RegisterAliases - You should define instances of this class to indicate which |
| 49 | // registers in the register file are aliased together. This allows the code |
| 50 | // generator to be careful not to put two values with overlapping live ranges |
| 51 | // into registers which alias. |
| 52 | // |
| 53 | class RegisterAliases<Register reg, list<Register> aliases> { |
| 54 | Register Reg = reg; |
| 55 | list<Register> Aliases = aliases; |
| 56 | } |
| 57 | |
| 58 | // RegisterClass - Now that all of the registers are defined, and aliases |
| 59 | // between registers are defined, specify which registers belong to which |
| 60 | // register classes. This also defines the default allocation order of |
| 61 | // registers by register allocators. |
| 62 | // |
| 63 | class RegisterClass<ValueType regType, int alignment, list<Register> regList> { |
Chris Lattner | 0ad1361 | 2003-07-30 22:16:41 +0000 | [diff] [blame] | 64 | // RegType - Specify the ValueType of the registers in this register class. |
| 65 | // Note that all registers in a register class must have the same ValueType. |
| 66 | // |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 67 | ValueType RegType = regType; |
Chris Lattner | 0ad1361 | 2003-07-30 22:16:41 +0000 | [diff] [blame] | 68 | |
| 69 | // Alignment - Specify the alignment required of the registers when they are |
| 70 | // stored or loaded to memory. |
| 71 | // |
Chris Lattner | de04dd7 | 2003-08-01 05:18:03 +0000 | [diff] [blame] | 72 | int Size = RegType.Size; |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 73 | int Alignment = alignment; |
Chris Lattner | 0ad1361 | 2003-07-30 22:16:41 +0000 | [diff] [blame] | 74 | |
| 75 | // MemberList - Specify which registers are in this class. If the |
| 76 | // allocation_order_* method are not specified, this also defines the order of |
| 77 | // allocation used by the register allocator. |
| 78 | // |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 79 | list<Register> MemberList = regList; |
Chris Lattner | 0ad1361 | 2003-07-30 22:16:41 +0000 | [diff] [blame] | 80 | |
Chris Lattner | be84e3c | 2003-08-01 22:21:49 +0000 | [diff] [blame] | 81 | // Methods - This member can be used to insert arbitrary code into a generated |
| 82 | // register class. The normal usage of this is to overload virtual methods. |
| 83 | code Methods = [{}]; |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | |
| 87 | //===----------------------------------------------------------------------===// |
Chris Lattner | a5100d9 | 2003-08-03 18:18:31 +0000 | [diff] [blame] | 88 | // Instruction set description - These classes correspond to the C++ classes in |
| 89 | // the Target/TargetInstrInfo.h file. |
Chris Lattner | 7c28952 | 2003-07-30 05:50:12 +0000 | [diff] [blame] | 90 | // |
| 91 | |
Misha Brukman | 01c1638 | 2003-05-29 18:48:17 +0000 | [diff] [blame] | 92 | class Instruction { |
| 93 | string Name; // The opcode string for this instruction |
| 94 | string Namespace = ""; |
| 95 | |
| 96 | list<Register> Uses = []; // Default to using no non-operand registers |
| 97 | list<Register> Defs = []; // Default to modifying no non-operand registers |
| 98 | |
| 99 | // These bits capture information about the high-level semantics of the |
| 100 | // instruction. |
Chris Lattner | 84c40c1 | 2003-07-29 23:02:49 +0000 | [diff] [blame] | 101 | bit isReturn = 0; // Is this instruction a return instruction? |
| 102 | bit isBranch = 0; // Is this instruction a branch instruction? |
| 103 | bit isCall = 0; // Is this instruction a call instruction? |
| 104 | bit isTwoAddress = 0; // Is this a two address instruction? |
| 105 | bit isTerminator = 0; // Is this part of the terminator for a basic block? |
Chris Lattner | 244883e | 2003-08-04 21:07:37 +0000 | [diff] [blame] | 106 | |
| 107 | // Pattern - Set to the DAG pattern for this instruction, if we know of one, |
| 108 | // otherwise, uninitialized. |
| 109 | dag Pattern; |
Chris Lattner | a5100d9 | 2003-08-03 18:18:31 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | // InstrInfo - This class should only be instantiated once to provide parameters |
| 113 | // which are global to the the target machine. |
| 114 | // |
| 115 | class InstrInfo { |
| 116 | Instruction PHIInst; |
Chris Lattner | 34a2068 | 2003-08-03 21:52:28 +0000 | [diff] [blame] | 117 | |
| 118 | // If the target wants to associate some target-specific information with each |
| 119 | // instruction, it should provide these two lists to indicate how to assemble |
| 120 | // the target specific information into the 32 bits available. |
| 121 | // |
| 122 | list<string> TSFlagsFields = []; |
| 123 | list<int> TSFlagsShifts = []; |
Chris Lattner | a5100d9 | 2003-08-03 18:18:31 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | |
| 127 | //===----------------------------------------------------------------------===// |
| 128 | // Target - This class contains the "global" target information |
| 129 | // |
| 130 | class Target { |
| 131 | // CalleeSavedRegisters - As you might guess, this is a list of the callee |
| 132 | // saved registers for a target. |
| 133 | list<Register> CalleeSavedRegisters = []; |
| 134 | |
| 135 | // PointerType - Specify the value type to be used to represent pointers in |
| 136 | // this target. Typically this is an i32 or i64 type. |
| 137 | ValueType PointerType; |
| 138 | |
| 139 | // InstructionSet - Instruction set description for this target |
| 140 | InstrInfo InstructionSet; |
Misha Brukman | 01c1638 | 2003-05-29 18:48:17 +0000 | [diff] [blame] | 141 | } |
Chris Lattner | 244883e | 2003-08-04 21:07:37 +0000 | [diff] [blame] | 142 | |
| 143 | |
| 144 | //===----------------------------------------------------------------------===// |
| 145 | // DAG node definitions used by the instruction selector... |
| 146 | // |
| 147 | def set; // FIXME: these are subject to substantial change |
| 148 | def plus; |
| 149 | def minus; |
| 150 | def mult; |
| 151 | def div; |
| 152 | def udiv; |
| 153 | def mod; |
| 154 | def umod; |
| 155 | def imm8; |
| 156 | def imm16; |
| 157 | def imm32; |