Target.td revision 37fefc20d3a1e3934a377567d54a141f67752227
131a217290cf376d0573fc36e21c8940987485019George Mount//===- Target.td - Target Independent TableGen interface ---*- tablegen -*-===// 231a217290cf376d0573fc36e21c8940987485019George Mount// 331a217290cf376d0573fc36e21c8940987485019George Mount// The LLVM Compiler Infrastructure 431a217290cf376d0573fc36e21c8940987485019George Mount// 531a217290cf376d0573fc36e21c8940987485019George Mount// This file is distributed under the University of Illinois Open Source 631a217290cf376d0573fc36e21c8940987485019George Mount// License. See LICENSE.TXT for details. 731a217290cf376d0573fc36e21c8940987485019George Mount// 831a217290cf376d0573fc36e21c8940987485019George Mount//===----------------------------------------------------------------------===// 931a217290cf376d0573fc36e21c8940987485019George Mount// 1031a217290cf376d0573fc36e21c8940987485019George Mount// This file defines the target-independent interfaces which should be 1131a217290cf376d0573fc36e21c8940987485019George Mount// implemented by each target which is using a TableGen based code generator. 1231a217290cf376d0573fc36e21c8940987485019George Mount// 1331a217290cf376d0573fc36e21c8940987485019George Mount//===----------------------------------------------------------------------===// 1431a217290cf376d0573fc36e21c8940987485019George Mount 1531a217290cf376d0573fc36e21c8940987485019George Mount// Include all information about LLVM intrinsics. 1631a217290cf376d0573fc36e21c8940987485019George Mountinclude "llvm/Intrinsics.td" 1731a217290cf376d0573fc36e21c8940987485019George Mount 18c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount//===----------------------------------------------------------------------===// 19c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// Register file description - These classes are used to fill in the target 2031a217290cf376d0573fc36e21c8940987485019George Mount// description classes. 217bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 22c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountclass RegisterClass; // Forward def 2331a217290cf376d0573fc36e21c8940987485019George Mount 24480ca829e2d3313740b4d14d30afbea6c98ff965George Mount// SubRegIndex - Use instances of SubRegIndex to identify subregisters. 2531a217290cf376d0573fc36e21c8940987485019George Mountclass SubRegIndex { 2631a217290cf376d0573fc36e21c8940987485019George Mount string Namespace = ""; 2731a217290cf376d0573fc36e21c8940987485019George Mount} 2831a217290cf376d0573fc36e21c8940987485019George Mount 29fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// RegAltNameIndex - The alternate name set to use for register operands of 3031a217290cf376d0573fc36e21c8940987485019George Mount// this register class when printing. 3131a217290cf376d0573fc36e21c8940987485019George Mountclass RegAltNameIndex { 32fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string Namespace = ""; 33fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount} 34c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef NoRegAltName : RegAltNameIndex; 3531a217290cf376d0573fc36e21c8940987485019George Mount 36caa03107d4322b0e30f92e6dc1eb1ea73b1bf747George Mount// Register - You should define one instance of this class for each register 3731a217290cf376d0573fc36e21c8940987485019George Mount// in the target machine. String n will become the "name" of the register. 3831a217290cf376d0573fc36e21c8940987485019George Mountclass Register<string n, list<string> altNames = []> { 3931a217290cf376d0573fc36e21c8940987485019George Mount string Namespace = ""; 4031a217290cf376d0573fc36e21c8940987485019George Mount string AsmName = n; 4131a217290cf376d0573fc36e21c8940987485019George Mount list<string> AltNames = altNames; 4231a217290cf376d0573fc36e21c8940987485019George Mount 4331a217290cf376d0573fc36e21c8940987485019George Mount // Aliases - A list of registers that this register overlaps with. A read or 4431a217290cf376d0573fc36e21c8940987485019George Mount // modification of this register can potentially read or modify the aliased 4531a217290cf376d0573fc36e21c8940987485019George Mount // registers. 4631a217290cf376d0573fc36e21c8940987485019George Mount list<Register> Aliases = []; 4731a217290cf376d0573fc36e21c8940987485019George Mount 4831a217290cf376d0573fc36e21c8940987485019George Mount // SubRegs - A list of registers that are parts of this register. Note these 4931a217290cf376d0573fc36e21c8940987485019George Mount // are "immediate" sub-registers and the registers within the list do not 5031a217290cf376d0573fc36e21c8940987485019George Mount // themselves overlap. e.g. For X86, EAX's SubRegs list contains only [AX], 5131a217290cf376d0573fc36e21c8940987485019George Mount // not [AX, AH, AL]. 5231a217290cf376d0573fc36e21c8940987485019George Mount list<Register> SubRegs = []; 5331a217290cf376d0573fc36e21c8940987485019George Mount 5431a217290cf376d0573fc36e21c8940987485019George Mount // SubRegIndices - For each register in SubRegs, specify the SubRegIndex used 5531a217290cf376d0573fc36e21c8940987485019George Mount // to address it. Sub-sub-register indices are automatically inherited from 5631a217290cf376d0573fc36e21c8940987485019George Mount // SubRegs. 5731a217290cf376d0573fc36e21c8940987485019George Mount list<SubRegIndex> SubRegIndices = []; 5831a217290cf376d0573fc36e21c8940987485019George Mount 5931a217290cf376d0573fc36e21c8940987485019George Mount // RegAltNameIndices - The alternate name indices which are valid for this 6031a217290cf376d0573fc36e21c8940987485019George Mount // register. 6131a217290cf376d0573fc36e21c8940987485019George Mount list<RegAltNameIndex> RegAltNameIndices = []; 6231a217290cf376d0573fc36e21c8940987485019George Mount 6331a217290cf376d0573fc36e21c8940987485019George Mount // CompositeIndices - Specify subreg indices that don't correspond directly to 6431a217290cf376d0573fc36e21c8940987485019George Mount // a register in SubRegs and are not inherited. The following formats are 6531a217290cf376d0573fc36e21c8940987485019George Mount // supported: 6631a217290cf376d0573fc36e21c8940987485019George Mount // 6731a217290cf376d0573fc36e21c8940987485019George Mount // (a) Identity - Reg:a == Reg 6831a217290cf376d0573fc36e21c8940987485019George Mount // (a b) Alias - Reg:a == Reg:b 6931a217290cf376d0573fc36e21c8940987485019George Mount // (a b,c) Composite - Reg:a == (Reg:b):c 7031a217290cf376d0573fc36e21c8940987485019George Mount // 7131a217290cf376d0573fc36e21c8940987485019George Mount // This can be used to disambiguate a sub-sub-register that exists in more 7231a217290cf376d0573fc36e21c8940987485019George Mount // than one subregister and other weird stuff. 7331a217290cf376d0573fc36e21c8940987485019George Mount list<dag> CompositeIndices = []; 7431a217290cf376d0573fc36e21c8940987485019George Mount 7531a217290cf376d0573fc36e21c8940987485019George Mount // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register. 7631a217290cf376d0573fc36e21c8940987485019George Mount // These values can be determined by locating the <target>.h file in the 7731a217290cf376d0573fc36e21c8940987485019George Mount // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The 7831a217290cf376d0573fc36e21c8940987485019George Mount // order of these names correspond to the enumeration used by gcc. A value of 7931a217290cf376d0573fc36e21c8940987485019George Mount // -1 indicates that the gcc number is undefined and -2 that register number 8031a217290cf376d0573fc36e21c8940987485019George Mount // is invalid for this mode/flavour. 8173f843de4b65772c624ca8ebb8c976a279e37ce9Craig Mautner list<int> DwarfNumbers = []; 8273f843de4b65772c624ca8ebb8c976a279e37ce9Craig Mautner 8362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // CostPerUse - Additional cost of instructions using this register compared 8431a217290cf376d0573fc36e21c8940987485019George Mount // to other registers in its class. The register allocator will try to 8531a217290cf376d0573fc36e21c8940987485019George Mount // minimize the number of instructions using a register with a CostPerUse. 8631a217290cf376d0573fc36e21c8940987485019George Mount // This is used by the x86-64 and ARM Thumb targets where some registers 8731a217290cf376d0573fc36e21c8940987485019George Mount // require larger instruction encodings. 8862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount int CostPerUse = 0; 8931a217290cf376d0573fc36e21c8940987485019George Mount} 9031a217290cf376d0573fc36e21c8940987485019George Mount 9131a217290cf376d0573fc36e21c8940987485019George Mount// RegisterWithSubRegs - This can be used to define instances of Register which 9231a217290cf376d0573fc36e21c8940987485019George Mount// need to specify sub-registers. 9331a217290cf376d0573fc36e21c8940987485019George Mount// List "subregs" specifies which registers are sub-registers to this one. This 9431a217290cf376d0573fc36e21c8940987485019George Mount// is used to populate the SubRegs and AliasSet fields of TargetRegisterDesc. 9531a217290cf376d0573fc36e21c8940987485019George Mount// This allows the code generator to be careful not to put two values with 9662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// overlapping live ranges into registers which alias. 9762ab9b78b77b7dd851c47115f4d8d7611d657585George Mountclass RegisterWithSubRegs<string n, list<Register> subregs> : Register<n> { 9831a217290cf376d0573fc36e21c8940987485019George Mount let SubRegs = subregs; 9931a217290cf376d0573fc36e21c8940987485019George Mount} 10031a217290cf376d0573fc36e21c8940987485019George Mount 10131a217290cf376d0573fc36e21c8940987485019George Mount// RegisterClass - Now that all of the registers are defined, and aliases 10231a217290cf376d0573fc36e21c8940987485019George Mount// between registers are defined, specify which registers belong to which 10331a217290cf376d0573fc36e21c8940987485019George Mount// register classes. This also defines the default allocation order of 10462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// registers by register allocators. 10562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// 10631a217290cf376d0573fc36e21c8940987485019George Mountclass RegisterClass<string namespace, list<ValueType> regTypes, int alignment, 10731a217290cf376d0573fc36e21c8940987485019George Mount dag regList, RegAltNameIndex idx = NoRegAltName> { 10862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount string Namespace = namespace; 10931a217290cf376d0573fc36e21c8940987485019George Mount 11062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // RegType - Specify the list ValueType of the registers in this register 11131a217290cf376d0573fc36e21c8940987485019George Mount // class. Note that all registers in a register class must have the same 11231a217290cf376d0573fc36e21c8940987485019George Mount // ValueTypes. This is a list because some targets permit storing different 11331a217290cf376d0573fc36e21c8940987485019George Mount // types in same register, for example vector values with 128-bit total size, 11431a217290cf376d0573fc36e21c8940987485019George Mount // but different count/size of items, like SSE on x86. 11531a217290cf376d0573fc36e21c8940987485019George Mount // 11631a217290cf376d0573fc36e21c8940987485019George Mount list<ValueType> RegTypes = regTypes; 11731a217290cf376d0573fc36e21c8940987485019George Mount 11831a217290cf376d0573fc36e21c8940987485019George Mount // Size - Specify the spill size in bits of the registers. A default value of 11931a217290cf376d0573fc36e21c8940987485019George Mount // zero lets tablgen pick an appropriate size. 12031a217290cf376d0573fc36e21c8940987485019George Mount int Size = 0; 12162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 12262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // Alignment - Specify the alignment required of the registers when they are 1237bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu // stored or loaded to memory. 1247bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu // 1257bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu int Alignment = alignment; 1267bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 12762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // CopyCost - This value is used to specify the cost of copying a value 128480ca829e2d3313740b4d14d30afbea6c98ff965George Mount // between two registers in this register class. The default value is one 12962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // meaning it takes a single instruction to perform the copying. A negative 13062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // value means copying is extremely expensive or impossible. 13126c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount int CopyCost = 1; 13231a217290cf376d0573fc36e21c8940987485019George Mount 13362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // MemberList - Specify which registers are in this class. If the 13431a217290cf376d0573fc36e21c8940987485019George Mount // allocation_order_* method are not specified, this also defines the order of 13531a217290cf376d0573fc36e21c8940987485019George Mount // allocation used by the register allocator. 13631a217290cf376d0573fc36e21c8940987485019George Mount // 13731a217290cf376d0573fc36e21c8940987485019George Mount dag MemberList = regList; 13831a217290cf376d0573fc36e21c8940987485019George Mount 13931a217290cf376d0573fc36e21c8940987485019George Mount // AltNameIndex - The alternate register name to use when printing operands 14031a217290cf376d0573fc36e21c8940987485019George Mount // of this register class. Every register in the register class must have 14131a217290cf376d0573fc36e21c8940987485019George Mount // a valid alternate name for the given index. 14231a217290cf376d0573fc36e21c8940987485019George Mount RegAltNameIndex altNameIndex = idx; 14331a217290cf376d0573fc36e21c8940987485019George Mount 14462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // SubRegClasses - Specify the register class of subregisters as a list of 14531a217290cf376d0573fc36e21c8940987485019George Mount // dags: (RegClass SubRegIndex, SubRegindex, ...) 14631a217290cf376d0573fc36e21c8940987485019George Mount list<dag> SubRegClasses = []; 14731a217290cf376d0573fc36e21c8940987485019George Mount 14831a217290cf376d0573fc36e21c8940987485019George Mount // isAllocatable - Specify that the register class can be used for virtual 14931a217290cf376d0573fc36e21c8940987485019George Mount // registers and register allocation. Some register classes are only used to 15031a217290cf376d0573fc36e21c8940987485019George Mount // model instruction operand constraints, and should have isAllocatable = 0. 15131a217290cf376d0573fc36e21c8940987485019George Mount bit isAllocatable = 1; 15231a217290cf376d0573fc36e21c8940987485019George Mount 15331a217290cf376d0573fc36e21c8940987485019George Mount // AltOrders - List of alternative allocation orders. The default order is 15431a217290cf376d0573fc36e21c8940987485019George Mount // MemberList itself, and that is good enough for most targets since the 15531a217290cf376d0573fc36e21c8940987485019George Mount // register allocators automatically remove reserved registers and move 15631a217290cf376d0573fc36e21c8940987485019George Mount // callee-saved registers to the end. 15731a217290cf376d0573fc36e21c8940987485019George Mount list<dag> AltOrders = []; 15831a217290cf376d0573fc36e21c8940987485019George Mount 15931a217290cf376d0573fc36e21c8940987485019George Mount // AltOrderSelect - The body of a function that selects the allocation order 16031a217290cf376d0573fc36e21c8940987485019George Mount // to use in a given machine function. The code will be inserted in a 16131a217290cf376d0573fc36e21c8940987485019George Mount // function like this: 16231a217290cf376d0573fc36e21c8940987485019George Mount // 16362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // static inline unsigned f(const MachineFunction &MF) { ... } 16431a217290cf376d0573fc36e21c8940987485019George Mount // 16531a217290cf376d0573fc36e21c8940987485019George Mount // The function should return 0 to select the default order defined by 16631a217290cf376d0573fc36e21c8940987485019George Mount // MemberList, 1 to select the first AltOrders entry and so on. 16731a217290cf376d0573fc36e21c8940987485019George Mount code AltOrderSelect = [{}]; 16831a217290cf376d0573fc36e21c8940987485019George Mount} 16931a217290cf376d0573fc36e21c8940987485019George Mount 17031a217290cf376d0573fc36e21c8940987485019George Mount// The memberList in a RegisterClass is a dag of set operations. TableGen 17131a217290cf376d0573fc36e21c8940987485019George Mount// evaluates these set operations and expand them into register lists. These 17231a217290cf376d0573fc36e21c8940987485019George Mount// are the most common operation, see test/TableGen/SetTheory.td for more 17362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// examples of what is possible: 17431a217290cf376d0573fc36e21c8940987485019George Mount// 17531a217290cf376d0573fc36e21c8940987485019George Mount// (add R0, R1, R2) - Set Union. Each argument can be an individual register, a 17631a217290cf376d0573fc36e21c8940987485019George Mount// register class, or a sub-expression. This is also the way to simply list 17731a217290cf376d0573fc36e21c8940987485019George Mount// registers. 17862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// 17931a217290cf376d0573fc36e21c8940987485019George Mount// (sub GPR, SP) - Set difference. Subtract the last arguments from the first. 18031a217290cf376d0573fc36e21c8940987485019George Mount// 18162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// (and GPR, CSR) - Set intersection. All registers from the first set that are 18231a217290cf376d0573fc36e21c8940987485019George Mount// also in the second set. 18362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// 18462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// (sequence "R%u", 0, 15) -> [R0, R1, ..., R15]. Generate a sequence of 185c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// numbered registers. 186c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// 187c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// (shl GPR, 4) - Remove the first N elements. 188c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// 189c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// (trunc GPR, 4) - Truncate after the first N elements. 190d265bd7446e662c9597226c596e8f91eda824982George Mount// 191d265bd7446e662c9597226c596e8f91eda824982George Mount// (rotl GPR, 1) - Rotate N places to the left. 192d265bd7446e662c9597226c596e8f91eda824982George Mount// 193d265bd7446e662c9597226c596e8f91eda824982George Mount// (rotr GPR, 1) - Rotate N places to the right. 194d265bd7446e662c9597226c596e8f91eda824982George Mount// 195a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mount// (decimate GPR, 2) - Pick every N'th element, starting with the first. 19662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// 19762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// All of these operators work on ordered sets, not lists. That means 19862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// duplicates are removed from sub-expressions. 199b694e080546316a27d22eba759027f6cb0a24705George Mount 2006558056e8fccc32f9e1dc59e46d09f8d916b7538George Mount// Set operators. The rest is defined in TargetSelectionDAG.td. 20162ab9b78b77b7dd851c47115f4d8d7611d657585George Mountdef sequence; 20262ab9b78b77b7dd851c47115f4d8d7611d657585George Mountdef decimate; 203c9b6df8fa4df3968b2420a52c5281b4765478f68George Mount 20467d924341a1d0994ac68b3b7898d5576edd987b4George Mount// RegisterTuples - Automatically generate super-registers by forming tuples of 20567d924341a1d0994ac68b3b7898d5576edd987b4George Mount// sub-registers. This is useful for modeling register sequence constraints 206fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// with pseudo-registers that are larger than the architectural registers. 207fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// 2080f0c473488f8e8becc8883d3cdd9610324610dc4George Mount// The sub-register lists are zipped together: 20967d924341a1d0994ac68b3b7898d5576edd987b4George Mount// 2108c2614ce4328640642d8e8be437859e0508a39b4George Mount// def EvenOdd : RegisterTuples<[sube, subo], [(add R0, R2), (add R1, R3)]>; 2118c2614ce4328640642d8e8be437859e0508a39b4George Mount// 2126558056e8fccc32f9e1dc59e46d09f8d916b7538George Mount// Generates the same registers as: 21362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// 21462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// let SubRegIndices = [sube, subo] in { 21562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// def R0_R1 : RegisterWithSubRegs<"", [R0, R1]>; 21662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// def R2_R3 : RegisterWithSubRegs<"", [R2, R3]>; 217c9b6df8fa4df3968b2420a52c5281b4765478f68George Mount// } 2188c2614ce4328640642d8e8be437859e0508a39b4George Mount// 2198c2614ce4328640642d8e8be437859e0508a39b4George Mount// The generated pseudo-registers inherit super-classes and fields from their 2201fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount// first sub-register. Most fields from the Register class are inferred, and 221ce725a47f6eee75a6ef86397e9b9fe471aeb1f84George Mount// the AsmName and Dwarf numbers are cleared. 2221732f528952ea2df0bfd503fabb958af03dbfc81George Mount// 2231732f528952ea2df0bfd503fabb958af03dbfc81George Mount// RegisterTuples instances can be used in other set operations to form 2241732f528952ea2df0bfd503fabb958af03dbfc81George Mount// register classes and so on. This is the only way of using the generated 225c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount// registers. 226c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mountclass RegisterTuples<list<SubRegIndex> Indices, list<dag> Regs> { 227c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount // SubRegs - N lists of registers to be zipped up. Super-registers are 228c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount // synthesized from the first element of each SubRegs list, the second 229c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount // element and so on. 230c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount list<dag> SubRegs = Regs; 231c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount 232c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount // SubRegIndices - N SubRegIndex instances. This provides the names of the 233c9a5227292ecc24f9735d4ba53cd1f9aaef3e6f4George Mount // sub-registers in the synthesized super-registers. 234b694e080546316a27d22eba759027f6cb0a24705George Mount list<SubRegIndex> SubRegIndices = Indices; 23548bd13c9cb2627847cf1f7707a084eb354e9c303George Mount 23648bd13c9cb2627847cf1f7707a084eb354e9c303George Mount // Compose sub-register indices like in a normal Register. 23748bd13c9cb2627847cf1f7707a084eb354e9c303George Mount list<dag> CompositeIndices = []; 23848bd13c9cb2627847cf1f7707a084eb354e9c303George Mount} 23962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 24031a217290cf376d0573fc36e21c8940987485019George Mount 24162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount//===----------------------------------------------------------------------===// 24231a217290cf376d0573fc36e21c8940987485019George Mount// DwarfRegNum - This class provides a mapping of the llvm register enumeration 24331a217290cf376d0573fc36e21c8940987485019George Mount// to the register numbering used by gcc and gdb. These values are used by a 24460625b02ac099bacc96a387ec270751745dafae0George Mount// debug information writer to describe where values may be located during 245b694e080546316a27d22eba759027f6cb0a24705George Mount// execution. 246b694e080546316a27d22eba759027f6cb0a24705George Mountclass DwarfRegNum<list<int> Numbers> { 247b694e080546316a27d22eba759027f6cb0a24705George Mount // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register. 24860625b02ac099bacc96a387ec270751745dafae0George Mount // These values can be determined by locating the <target>.h file in the 24960625b02ac099bacc96a387ec270751745dafae0George Mount // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The 25060625b02ac099bacc96a387ec270751745dafae0George Mount // order of these names correspond to the enumeration used by gcc. A value of 25160625b02ac099bacc96a387ec270751745dafae0George Mount // -1 indicates that the gcc number is undefined and -2 that register number 25260625b02ac099bacc96a387ec270751745dafae0George Mount // is invalid for this mode/flavour. 253653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount list<int> DwarfNumbers = Numbers; 25460625b02ac099bacc96a387ec270751745dafae0George Mount} 25560625b02ac099bacc96a387ec270751745dafae0George Mount 25660625b02ac099bacc96a387ec270751745dafae0George Mount// DwarfRegAlias - This class declares that a given register uses the same dwarf 25760625b02ac099bacc96a387ec270751745dafae0George Mount// numbers as another one. This is useful for making it clear that the two 25831a217290cf376d0573fc36e21c8940987485019George Mount// registers do have the same number. It also lets us build a mapping 25931a217290cf376d0573fc36e21c8940987485019George Mount// from dwarf register number to llvm register. 26031a217290cf376d0573fc36e21c8940987485019George Mountclass DwarfRegAlias<Register reg> { 26131a217290cf376d0573fc36e21c8940987485019George Mount Register DwarfAlias = reg; 262a2bbbb3bac464c3a52e33008401fed4a7542744cGeorge Mount} 26331a217290cf376d0573fc36e21c8940987485019George Mount 26431a217290cf376d0573fc36e21c8940987485019George Mount//===----------------------------------------------------------------------===// 26531a217290cf376d0573fc36e21c8940987485019George Mount// Pull in the common support for scheduling 26662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount// 26762ab9b78b77b7dd851c47115f4d8d7611d657585George Mountinclude "llvm/Target/TargetSchedule.td" 26862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 26962ab9b78b77b7dd851c47115f4d8d7611d657585George Mountclass Predicate; // Forward def 27062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 271c6186bffe477b996e388046e8761908b813fd07fGeorge Mount//===----------------------------------------------------------------------===// 272c6186bffe477b996e388046e8761908b813fd07fGeorge Mount// Instruction set description - These classes correspond to the C++ classes in 273c6186bffe477b996e388046e8761908b813fd07fGeorge Mount// the Target/TargetInstrInfo.h file. 274c6186bffe477b996e388046e8761908b813fd07fGeorge Mount// 275c6186bffe477b996e388046e8761908b813fd07fGeorge Mountclass Instruction { 27631a217290cf376d0573fc36e21c8940987485019George Mount string Namespace = ""; 27762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 27831a217290cf376d0573fc36e21c8940987485019George Mount dag OutOperandList; // An dag containing the MI def operand list. 27931a217290cf376d0573fc36e21c8940987485019George Mount dag InOperandList; // An dag containing the MI use operand list. 28062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount string AsmString = ""; // The .s format to print the instruction with. 28162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 28262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // Pattern - Set to the DAG pattern for this instruction, if we know of one, 28331a217290cf376d0573fc36e21c8940987485019George Mount // otherwise, uninitialized. 2848e43d6d62fb3a94b2a7175d1dee3174c62f217baGeorge Mount list<dag> Pattern; 2858e43d6d62fb3a94b2a7175d1dee3174c62f217baGeorge Mount 28662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // The follow state will eventually be inferred automatically from the 28731a217290cf376d0573fc36e21c8940987485019George Mount // instruction pattern. 28831a217290cf376d0573fc36e21c8940987485019George Mount 28931a217290cf376d0573fc36e21c8940987485019George Mount list<Register> Uses = []; // Default to using no non-operand registers 29062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount list<Register> Defs = []; // Default to modifying no non-operand registers 29162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 29231a217290cf376d0573fc36e21c8940987485019George Mount // Predicates - List of predicates which will be turned into isel matching 29331a217290cf376d0573fc36e21c8940987485019George Mount // code. 29462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount list<Predicate> Predicates = []; 29562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 29662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // Size - Size of encoded instruction, or zero if the size cannot be determined 2970a2ae002e60f7ea9b6bea282086b5eb0ae3c6e51George Mount // from the opcode. 298080443bcb63418245c2408500db735fece5e7083George Mount int Size = 0; 29962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 30031a217290cf376d0573fc36e21c8940987485019George Mount // DecoderNamespace - The "namespace" in which this instruction exists, on 30131a217290cf376d0573fc36e21c8940987485019George Mount // targets like ARM which multiple ISA namespaces exist. 302700db2a325bced35cebc403f272f988fad522892George Mount string DecoderNamespace = ""; 303700db2a325bced35cebc403f272f988fad522892George Mount 3041fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount // Code size, for instruction selection. 3051fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount // FIXME: What does this actually mean? 3068c2614ce4328640642d8e8be437859e0508a39b4George Mount int CodeSize = 0; 3078c2614ce4328640642d8e8be437859e0508a39b4George Mount 3088881502da5b319e139ab85c1825d2d2d239356a1George Mount // Added complexity passed onto matching pattern. 3098881502da5b319e139ab85c1825d2d2d239356a1George Mount int AddedComplexity = 0; 3108881502da5b319e139ab85c1825d2d2d239356a1George Mount 31131a217290cf376d0573fc36e21c8940987485019George Mount // These bits capture information about the high-level semantics of the 31231a217290cf376d0573fc36e21c8940987485019George Mount // instruction. 313d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount bit isReturn = 0; // Is this instruction a return instruction? 314d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount bit isBranch = 0; // Is this instruction a branch instruction? 31531a217290cf376d0573fc36e21c8940987485019George Mount bit isIndirectBranch = 0; // Is this instruction an indirect branch? 3168881502da5b319e139ab85c1825d2d2d239356a1George Mount bit isCompare = 0; // Is this instruction a comparison instruction? 3178881502da5b319e139ab85c1825d2d2d239356a1George Mount bit isMoveImm = 0; // Is this instruction a move immediate instruction? 3188881502da5b319e139ab85c1825d2d2d239356a1George Mount bit isBitcast = 0; // Is this instruction a bitcast instruction? 3198881502da5b319e139ab85c1825d2d2d239356a1George Mount bit isBarrier = 0; // Can control flow fall through this instruction? 3208881502da5b319e139ab85c1825d2d2d239356a1George Mount bit isCall = 0; // Is this instruction a call instruction? 3218881502da5b319e139ab85c1825d2d2d239356a1George Mount bit canFoldAsLoad = 0; // Can this be folded as a simple memory operand? 3228881502da5b319e139ab85c1825d2d2d239356a1George Mount bit mayLoad = 0; // Is it possible for this inst to read memory? 3238881502da5b319e139ab85c1825d2d2d239356a1George Mount bit mayStore = 0; // Is it possible for this inst to write memory? 32431a217290cf376d0573fc36e21c8940987485019George Mount bit isConvertibleToThreeAddress = 0; // Can this 2-addr instruction promote? 32531a217290cf376d0573fc36e21c8940987485019George Mount bit isCommutable = 0; // Is this 3 operand instruction commutable? 326d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount bit isTerminator = 0; // Is this part of the terminator for a basic block? 327d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount bit isReMaterializable = 0; // Is this instruction re-materializable? 328d4c3c91dd0757eec9703ef90ea4c5a7ee99f18caGeorge Mount bit isPredicable = 0; // Is this instruction predicable? 329fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount bit hasDelaySlot = 0; // Does this instruction have an delay slot? 330fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount bit usesCustomInserter = 0; // Pseudo instr needing special help. 331fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount bit hasPostISelHook = 0; // To be *adjusted* after isel by target hook. 332fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount bit hasCtrlDep = 0; // Does this instruction r/w ctrl-flow chains? 333fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount bit isNotDuplicable = 0; // Is it unsafe to duplicate this instruction? 334fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount bit isAsCheapAsAMove = 0; // As cheap (or cheaper) than a move instruction. 33531a217290cf376d0573fc36e21c8940987485019George Mount bit hasExtraSrcRegAllocReq = 0; // Sources have special regalloc requirement? 33631a217290cf376d0573fc36e21c8940987485019George Mount bit hasExtraDefRegAllocReq = 0; // Defs have special regalloc requirement? 33731a217290cf376d0573fc36e21c8940987485019George Mount bit isPseudo = 0; // Is this instruction a pseudo-instruction? 3388881502da5b319e139ab85c1825d2d2d239356a1George Mount // If so, won't have encoding information for 3398881502da5b319e139ab85c1825d2d2d239356a1George Mount // the [MC]CodeEmitter stuff. 34031a217290cf376d0573fc36e21c8940987485019George Mount 34162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // Side effect flags - When set, the flags have these meanings: 34262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // 3438881502da5b319e139ab85c1825d2d2d239356a1George Mount // hasSideEffects - The instruction has side effects that are not 34431a217290cf376d0573fc36e21c8940987485019George Mount // captured by any operands of the instruction or other flags. 34531a217290cf376d0573fc36e21c8940987485019George Mount // 34631a217290cf376d0573fc36e21c8940987485019George Mount // neverHasSideEffects - Set on an instruction with no pattern if it has no 34731a217290cf376d0573fc36e21c8940987485019George Mount // side effects. 34862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount bit hasSideEffects = 0; 34962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount bit neverHasSideEffects = 0; 35062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 35162ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // Is this instruction a "real" instruction (with a distinct machine 35262ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // encoding), or is it a pseudo instruction used for codegen modeling 35362ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // purposes. 35462ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // FIXME: For now this is distinct from isPseudo, above, as code-gen-only 35562ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // instructions can (and often do) still have encoding information 35662ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // associated with them. Once we've migrated all of them over to true 35762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // pseudo-instructions that are lowered to real instructions prior to 35862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount // the printer/emitter, we can remove this attribute and just use isPseudo. 35962ab9b78b77b7dd851c47115f4d8d7611d657585George Mount bit isCodeGenOnly = 0; 36062ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 3611fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount // Is this instruction a pseudo instruction for use by the assembler parser. 3621fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount bit isAsmParserOnly = 0; 3631fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount 364ce725a47f6eee75a6ef86397e9b9fe471aeb1f84George Mount InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling. 365ce725a47f6eee75a6ef86397e9b9fe471aeb1f84George Mount 366ce725a47f6eee75a6ef86397e9b9fe471aeb1f84George Mount string Constraints = ""; // OperandConstraint, e.g. $src = $dst. 367caa03107d4322b0e30f92e6dc1eb1ea73b1bf747George Mount 368ce725a47f6eee75a6ef86397e9b9fe471aeb1f84George Mount /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not 36948bd13c9cb2627847cf1f7707a084eb354e9c303George Mount /// be encoded into the output machineinstr. 37048bd13c9cb2627847cf1f7707a084eb354e9c303George Mount string DisableEncoding = ""; 37148bd13c9cb2627847cf1f7707a084eb354e9c303George Mount 37248bd13c9cb2627847cf1f7707a084eb354e9c303George Mount string PostEncoderMethod = ""; 3731fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount string DecoderMethod = ""; 3741fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount 3751fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc. 3761fecfb2ddcdf4335ff543bdd549b8e4d36139da8George Mount bits<64> TSFlags = 0; 37762ab9b78b77b7dd851c47115f4d8d7611d657585George Mount 37862ab9b78b77b7dd851c47115f4d8d7611d657585George Mount ///@name Assembler Parser Support 379080443bcb63418245c2408500db735fece5e7083George Mount ///@{ 380080443bcb63418245c2408500db735fece5e7083George Mount 381a712e8cc2f16ac32ee5f1bbf5b962969f2f3451eGeorge Mount string AsmMatchConverter = ""; 382080443bcb63418245c2408500db735fece5e7083George Mount 383fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount ///@} 3847bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu} 385c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 386c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// PseudoInstExpansion - Expansion information for a pseudo-instruction. 387c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// Which instruction it expands to and how the operands map from the 388c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// pseudo. 389c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountclass PseudoInstExpansion<dag Result> { 390c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount dag ResultInst = Result; // The instruction to generate. 391c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount bit isPseudo = 1; 392c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount} 393c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 394c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// Predicates - These are extra conditionals which are turned into instruction 395c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// selector matching code. Currently each predicate is just a string. 396c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountclass Predicate<string cond> { 397c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount string CondString = cond; 3987bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 3997bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu /// AssemblerMatcherPredicate - If this feature can be used by the assembler 400c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// matcher, this is true. Targets should set this by inheriting their 401c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// feature from the AssemblerPredicate class in addition to Predicate. 402c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount bit AssemblerMatcherPredicate = 0; 403c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 404c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// AssemblerCondString - Name of the subtarget feature being tested used 405c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// as alternative condition string used for assembler matcher. 40626c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount /// e.g. "ModeThumb" is translated to "(Bits & ModeThumb) != 0". 40726c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount /// "!ModeThumb" is translated to "(Bits & ModeThumb) == 0". 408c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// It can also list multiple features separated by ",". 4097bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu /// e.g. "ModeThumb,FeatureThumb2" is translated to 4107bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu /// "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0". 4117bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu string AssemblerCondString = ""; 4127bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu} 413c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 4147bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// NoHonorSignDependentRounding - This predicate is true if support for 4157bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// sign-dependent-rounding is not enabled. 4167bf379c8af399626d5b8b568fe1d4f96f56badccDake Gudef NoHonorSignDependentRounding 417480ca829e2d3313740b4d14d30afbea6c98ff965George Mount : Predicate<"!HonorSignDependentRoundingFPMath()">; 418480ca829e2d3313740b4d14d30afbea6c98ff965George Mount 4197bf379c8af399626d5b8b568fe1d4f96f56badccDake Guclass Requires<list<Predicate> preds> { 4207bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu list<Predicate> Predicates = preds; 421fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount} 4227bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 4237bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// ops definition - This is just a simple marker used to identify the operand 4247bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// list for an instruction. outs and ins are identical both syntactically and 4257bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// semanticallyr; they are used to define def operands and use operands to 4267bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// improve readibility. This should be used like this: 4277bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar. 4287bf379c8af399626d5b8b568fe1d4f96f56badccDake Gudef ops; 4297bf379c8af399626d5b8b568fe1d4f96f56badccDake Gudef outs; 4307bf379c8af399626d5b8b568fe1d4f96f56badccDake Gudef ins; 4317bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 4327bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// variable_ops definition - Mark this instruction as taking a variable number 4337bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// of operands. 4347bf379c8af399626d5b8b568fe1d4f96f56badccDake Gudef variable_ops; 4357bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 4367bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 4377bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// PointerLikeRegClass - Values that are designed to have pointer width are 4387bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// derived from this. TableGen treats the register class as having a symbolic 4397bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// type that it doesn't know, and resolves the actual regclass to use by using 4407bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// the TargetRegisterInfo::getPointerRegClass() hook at codegen time. 441fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mountclass PointerLikeRegClass<int Kind> { 4427bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu int RegClassKind = Kind; 4437bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu} 4447bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 4457bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 4467bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// ptr_rc definition - Mark this operand as being a pointer value whose 4477bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// register class is resolved dynamically via a callback to TargetInstrInfo. 4487bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// FIXME: We should probably change this to a class which contain a list of 4497bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// flags. But currently we have but one flag. 4507bf379c8af399626d5b8b568fe1d4f96f56badccDake Gudef ptr_rc : PointerLikeRegClass<0>; 4517bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 452c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// unknown definition - Mark this operand as being of unknown type, causing 453c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// it to be resolved by inference in the context it is used. 454c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef unknown; 455c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 4567bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// AsmOperandClass - Representation for the kinds of operands which the target 457c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// specific parser can create and the assembly matcher may need to distinguish. 458c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// 459fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// Operand classes are used to define the order in which instructions are 460fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// matched, to ensure that the instruction which gets matched for any 461fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// particular list of operands is deterministic. 462fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// 463fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// The target specific parser must be able to classify a parsed operand into a 464fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// unique class which does not partially overlap with any other classes. It can 465fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// match a subset of some other class, in which case the super class field 466c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu/// should be defined. 467c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountclass AsmOperandClass { 468c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu /// The name to use for this class, which should be usable as an enum value. 469c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu string Name = ?; 470c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 4717bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu /// The super classes of this operand. 4727bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu list<AsmOperandClass> SuperClasses = []; 4731732f528952ea2df0bfd503fabb958af03dbfc81George Mount 4741732f528952ea2df0bfd503fabb958af03dbfc81George Mount /// The name of the method on the target specific operand to call to test 475c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// whether the operand is an instance of this class. If not set, this will 476c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// default to "isFoo", where Foo is the AsmOperandClass name. The method 477c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu /// signature should be: 478c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// bool isFoo() const; 479c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu string PredicateMethod = ?; 4807bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu 4817bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu /// The name of the method on the target specific operand to call to add the 482c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// target specific operand to an MCInst. If not set, this will default to 483c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount /// "addFooOperands", where Foo is the AsmOperandClass name. The method 4841732f528952ea2df0bfd503fabb958af03dbfc81George Mount /// signature should be: 4851732f528952ea2df0bfd503fabb958af03dbfc81George Mount /// void addFooOperands(MCInst &Inst, unsigned N) const; 4861732f528952ea2df0bfd503fabb958af03dbfc81George Mount string RenderMethod = ?; 487fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 488fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount /// The name of the method on the target specific operand to call to custom 489fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount /// handle the operand parsing. This is useful when the operands do not relate 490fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount /// to immediates or registers and are very instruction specific (as flags to 4911732f528952ea2df0bfd503fabb958af03dbfc81George Mount /// set in a processor register, coprocessor number, ...). 4921732f528952ea2df0bfd503fabb958af03dbfc81George Mount string ParserMethod = ?; 4931732f528952ea2df0bfd503fabb958af03dbfc81George Mount} 494fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 495c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef ImmAsmOperand : AsmOperandClass { 496fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount let Name = "Imm"; 4976e7fb60b93d3449d256282a9cc34ba3356add90eGeorge Mount} 49848bd13c9cb2627847cf1f7707a084eb354e9c303George Mount 49948bd13c9cb2627847cf1f7707a084eb354e9c303George Mount/// Operand Types - These provide the built-in operand types that may be used 50048bd13c9cb2627847cf1f7707a084eb354e9c303George Mount/// by a target. Targets can optionally provide their own operand types as 50148bd13c9cb2627847cf1f7707a084eb354e9c303George Mount/// needed, though this should not be needed for RISC targets. 50248bd13c9cb2627847cf1f7707a084eb354e9c303George Mountclass Operand<ValueType ty> { 50348bd13c9cb2627847cf1f7707a084eb354e9c303George Mount ValueType Type = ty; 50448bd13c9cb2627847cf1f7707a084eb354e9c303George Mount string PrintMethod = "printOperand"; 50548bd13c9cb2627847cf1f7707a084eb354e9c303George Mount string EncoderMethod = ""; 50648bd13c9cb2627847cf1f7707a084eb354e9c303George Mount string DecoderMethod = ""; 507c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount string AsmOperandLowerMethod = ?; 50848bd13c9cb2627847cf1f7707a084eb354e9c303George Mount string OperandType = "OPERAND_UNKNOWN"; 50948bd13c9cb2627847cf1f7707a084eb354e9c303George Mount dag MIOperandInfo = (ops); 510c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 511c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // ParserMatchClass - The "match class" that operands of this type fit 512c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // in. Match classes are used to define the order in which instructions are 513c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // match, to ensure that which instructions gets matched is deterministic. 514c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // 515c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // The target specific parser must be able to classify an parsed operand into 516c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // a unique class, which does not partially overlap with any other classes. It 517c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // can match a subset of some other class, in which case the AsmOperandClass 518c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // should declare the other operand as one of its super classes. 519c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu AsmOperandClass ParserMatchClass = ImmAsmOperand; 520c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu} 521c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu 52226c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mountclass RegisterOperand<RegisterClass regclass, string pm = "printOperand"> { 52326c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount // RegClass - The register class of the operand. 524c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount RegisterClass RegClass = regclass; 525c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // PrintMethod - The target method to call to print register operands of 526c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // this type. The method normally will just use an alt-name index to look 527c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // up the name to print. Default to the generic printOperand(). 528c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount string PrintMethod = pm; 529c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // ParserMatchClass - The "match class" that operands of this type fit 530c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // in. Match classes are used to define the order in which instructions are 531c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // match, to ensure that which instructions gets matched is deterministic. 532c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // 533c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // The target specific parser must be able to classify an parsed operand into 534c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // a unique class, which does not partially overlap with any other classes. It 535c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // can match a subset of some other class, in which case the AsmOperandClass 536c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // should declare the other operand as one of its super classes. 537c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu AsmOperandClass ParserMatchClass; 538c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu} 539c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu 540c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountlet OperandType = "OPERAND_IMMEDIATE" in { 541c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gudef i1imm : Operand<i1>; 542c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef i8imm : Operand<i8>; 543c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef i16imm : Operand<i16>; 544c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef i32imm : Operand<i32>; 545c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef i64imm : Operand<i64>; 546c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 547c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef f32imm : Operand<f32>; 548c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef f64imm : Operand<f64>; 549c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount} 550c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 5517bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu/// zero_reg definition - Special node to stand for the zero register. 55248bd13c9cb2627847cf1f7707a084eb354e9c303George Mount/// 55348bd13c9cb2627847cf1f7707a084eb354e9c303George Mountdef zero_reg; 55448bd13c9cb2627847cf1f7707a084eb354e9c303George Mount 55548bd13c9cb2627847cf1f7707a084eb354e9c303George Mount/// PredicateOperand - This can be used to define a predicate operand for an 556c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// instruction. OpTypes specifies the MIOperandInfo for the operand, and 557c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// AlwaysVal specifies the value of this predicate when set to "always 558c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// execute". 559480ca829e2d3313740b4d14d30afbea6c98ff965George Mountclass PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal> 560480ca829e2d3313740b4d14d30afbea6c98ff965George Mount : Operand<ty> { 5611732f528952ea2df0bfd503fabb958af03dbfc81George Mount let MIOperandInfo = OpTypes; 5626558056e8fccc32f9e1dc59e46d09f8d916b7538George Mount dag DefaultOps = AlwaysVal; 563480ca829e2d3313740b4d14d30afbea6c98ff965George Mount} 564480ca829e2d3313740b4d14d30afbea6c98ff965George Mount 565480ca829e2d3313740b4d14d30afbea6c98ff965George Mount/// OptionalDefOperand - This is used to define a optional definition operand 566c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// for an instruction. DefaultOps is the register the operand represents if 567c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount/// none is supplied, e.g. zero_reg. 568c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountclass OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops> 569c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount : Operand<ty> { 570c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let MIOperandInfo = OpTypes; 571c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount dag DefaultOps = defaultops; 572c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount} 573c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu 574c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu 575c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// InstrInfo - This class should only be instantiated once to provide parameters 576c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu// which are global to the target machine. 577c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu// 578c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Guclass InstrInfo { 579c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // Target can specify its instructions in either big or little-endian formats. 580c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // For instance, while both Sparc and PowerPC are big-endian platforms, the 581c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // Sparc manual specifies its instructions in the format [31..0] (big), while 582c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // PowerPC specifies them using the format [0..31] (little). 583c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu bit isLittleEndianEncoding = 0; 584c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu} 58526c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount 58626c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount// Standard Pseudo Instructions. 58726c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount// This list must match TargetOpcodes.h and CodeGenTarget.cpp. 588c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu// Only these instructions are allowed in the TargetOpcode namespace. 589c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gulet isCodeGenOnly = 1, Namespace = "TargetOpcode" in { 590c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gudef PHI : Instruction { 591c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu let OutOperandList = (outs); 592c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu let InOperandList = (ins variable_ops); 593c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let AsmString = "PHINODE"; 594c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount} 595c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef INLINEASM : Instruction { 596c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let OutOperandList = (outs); 597c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let InOperandList = (ins variable_ops); 5987bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let AsmString = ""; 5997bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let neverHasSideEffects = 1; // Note side effect is encoded in an operand. 600f03c139018dd5b6f1ea53ac902caec7b6ee9ddd3Dake Gu} 601c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef PROLOG_LABEL : Instruction { 602c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let OutOperandList = (outs); 6037bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let InOperandList = (ins i32imm:$id); 604c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let AsmString = ""; 605c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let hasCtrlDep = 1; 606c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let isNotDuplicable = 1; 607c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount} 608a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mountdef EH_LABEL : Instruction { 609a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mount let OutOperandList = (outs); 610a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mount let InOperandList = (ins i32imm:$id); 611a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mount let AsmString = ""; 612b694e080546316a27d22eba759027f6cb0a24705George Mount let hasCtrlDep = 1; 6130f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let isNotDuplicable = 1; 614a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mount} 615a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mountdef GC_LABEL : Instruction { 616fc0fc0e341f2a2d707d5a8eafd65db34bdffb35cDake Gu let OutOperandList = (outs); 617a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mount let InOperandList = (ins i32imm:$id); 618a0a0260e48e1ee4e9b5d98b49571e8d2a6fd6c3aGeorge Mount let AsmString = ""; 619ed1e01d7e431edbcaab983b4b240418f2b090facGeorge Mount let hasCtrlDep = 1; 620ed1e01d7e431edbcaab983b4b240418f2b090facGeorge Mount let isNotDuplicable = 1; 621ed1e01d7e431edbcaab983b4b240418f2b090facGeorge Mount} 622ed1e01d7e431edbcaab983b4b240418f2b090facGeorge Mountdef KILL : Instruction { 6230f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let OutOperandList = (outs); 624fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount let InOperandList = (ins variable_ops); 625fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount let AsmString = ""; 6260f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let neverHasSideEffects = 1; 6270f0c473488f8e8becc8883d3cdd9610324610dc4George Mount} 6280f0c473488f8e8becc8883d3cdd9610324610dc4George Mountdef EXTRACT_SUBREG : Instruction { 6290f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let OutOperandList = (outs unknown:$dst); 6300f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let InOperandList = (ins unknown:$supersrc, i32imm:$subidx); 6310f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let AsmString = ""; 6320f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let neverHasSideEffects = 1; 6330f0c473488f8e8becc8883d3cdd9610324610dc4George Mount} 634ce2ee3d6de670e52abed7f432778701113ba9c07George Mountdef INSERT_SUBREG : Instruction { 6350f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let OutOperandList = (outs unknown:$dst); 6360f0c473488f8e8becc8883d3cdd9610324610dc4George Mount let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx); 637653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let AsmString = ""; 638653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let neverHasSideEffects = 1; 639653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let Constraints = "$supersrc = $dst"; 640653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount} 641653ea66a9f609deec4b4370550396c47a85d713cGeorge Mountdef IMPLICIT_DEF : Instruction { 642653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let OutOperandList = (outs unknown:$dst); 643653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let InOperandList = (ins); 644653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let AsmString = ""; 645653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let neverHasSideEffects = 1; 646653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let isReMaterializable = 1; 647653ea66a9f609deec4b4370550396c47a85d713cGeorge Mount let isAsCheapAsAMove = 1; 648b5ef7f8c6d4629b2998de6c0b27bc1a4779b3e49George Mount} 649b5ef7f8c6d4629b2998de6c0b27bc1a4779b3e49George Mountdef SUBREG_TO_REG : Instruction { 650b5ef7f8c6d4629b2998de6c0b27bc1a4779b3e49George Mount let OutOperandList = (outs unknown:$dst); 651c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx); 652c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let AsmString = ""; 653c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let neverHasSideEffects = 1; 654c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount} 655c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef COPY_TO_REGCLASS : Instruction { 656c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let OutOperandList = (outs unknown:$dst); 657c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let InOperandList = (ins unknown:$src, i32imm:$regclass); 658c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let AsmString = ""; 6598e43d6d62fb3a94b2a7175d1dee3174c62f217baGeorge Mount let neverHasSideEffects = 1; 660c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let isAsCheapAsAMove = 1; 661480ca829e2d3313740b4d14d30afbea6c98ff965George Mount} 6627bf379c8af399626d5b8b568fe1d4f96f56badccDake Gudef DBG_VALUE : Instruction { 663c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let OutOperandList = (outs); 6647bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let InOperandList = (ins variable_ops); 6657bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let AsmString = "DBG_VALUE"; 6668e43d6d62fb3a94b2a7175d1dee3174c62f217baGeorge Mount let neverHasSideEffects = 1; 6677bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu} 668c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef REG_SEQUENCE : Instruction { 6697bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let OutOperandList = (outs unknown:$dst); 6707bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let InOperandList = (ins variable_ops); 6717bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let AsmString = ""; 6727bf379c8af399626d5b8b568fe1d4f96f56badccDake Gu let neverHasSideEffects = 1; 673c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount let isAsCheapAsAMove = 1; 67426c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount} 675c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountdef COPY : Instruction { 6761732f528952ea2df0bfd503fabb958af03dbfc81George Mount let OutOperandList = (outs unknown:$dst); 6771732f528952ea2df0bfd503fabb958af03dbfc81George Mount let InOperandList = (ins unknown:$src); 6781732f528952ea2df0bfd503fabb958af03dbfc81George Mount let AsmString = ""; 6791732f528952ea2df0bfd503fabb958af03dbfc81George Mount let neverHasSideEffects = 1; 6801732f528952ea2df0bfd503fabb958af03dbfc81George Mount let isAsCheapAsAMove = 1; 681480ca829e2d3313740b4d14d30afbea6c98ff965George Mount} 682480ca829e2d3313740b4d14d30afbea6c98ff965George Mount} 683c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 684c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount//===----------------------------------------------------------------------===// 685c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// AsmParser - This class can be implemented by targets that wish to implement 686c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// .s file parsing. 687c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// 688c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel 689c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// syntax on X86 for example). 690c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount// 691c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mountclass AsmParser { 692c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // AsmParserClassName - This specifies the suffix to use for the asmparser 693c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // class. Generated AsmParser classes are always prefixed with the target 694c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // name. 695c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount string AsmParserClassName = "AsmParser"; 696c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 697c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // AsmParserInstCleanup - If non-empty, this is the name of a custom member 698c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // function of the AsmParser class to call on every matched instruction. 69967d924341a1d0994ac68b3b7898d5576edd987b4George Mount // This can be used to perform target specific instruction post-processing. 70067d924341a1d0994ac68b3b7898d5576edd987b4George Mount string AsmParserInstCleanup = ""; 70167d924341a1d0994ac68b3b7898d5576edd987b4George Mount 70267d924341a1d0994ac68b3b7898d5576edd987b4George Mount // Variant - AsmParsers can be of multiple different variants. Variants are 70367d924341a1d0994ac68b3b7898d5576edd987b4George Mount // used to support targets that need to parser multiple formats for the 70467d924341a1d0994ac68b3b7898d5576edd987b4George Mount // assembly language. 70567d924341a1d0994ac68b3b7898d5576edd987b4George Mount int Variant = 0; 70667d924341a1d0994ac68b3b7898d5576edd987b4George Mount 70767d924341a1d0994ac68b3b7898d5576edd987b4George Mount // CommentDelimiter - If given, the delimiter string used to recognize 70867d924341a1d0994ac68b3b7898d5576edd987b4George Mount // comments which are hard coded in the .td assembler strings for individual 70913ccb79b34f6db1580714ea980c8490121d7e5aeGeorge Mount // instructions. 71013ccb79b34f6db1580714ea980c8490121d7e5aeGeorge Mount string CommentDelimiter = ""; 71113ccb79b34f6db1580714ea980c8490121d7e5aeGeorge Mount 71213ccb79b34f6db1580714ea980c8490121d7e5aeGeorge Mount // RegisterPrefix - If given, the token prefix which indicates a register 713fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // token. This is used by the matcher to automatically recognize hard coded 714b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount // register tokens as constrained registers, instead of tokens, for the 715b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount // purposes of matching. 716b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount string RegisterPrefix = ""; 717fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount} 718fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mountdef DefaultAsmParser : AsmParser; 719fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 720fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// AssemblerPredicate - This is a Predicate that can be used when the assembler 721fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// matches instructions and aliases. 722fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mountclass AssemblerPredicate<string cond> { 723fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount bit AssemblerMatcherPredicate = 1; 724fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string AssemblerCondString = cond; 725fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount} 7266e7fb60b93d3449d256282a9cc34ba3356add90eGeorge Mount 727fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 728fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 729fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// MnemonicAlias - This class allows targets to define assembler mnemonic 730fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// aliases. This should be used when all forms of one mnemonic are accepted 731fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// with a different mnemonic. For example, X86 allows: 732fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// sal %al, 1 -> shl %al, 1 733fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// sal %ax, %cl -> shl %ax, %cl 734fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// sal %eax, %cl -> shl %eax, %cl 735fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// etc. Though "sal" is accepted with many forms, all of them are directly 736fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// translated to a shl, so it can be handled with (in the case of X86, it 737fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// actually has one for each suffix as well): 738fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// def : MnemonicAlias<"sal", "shl">; 739fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// 740fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// Mnemonic aliases are mapped before any other translation in the match phase, 741fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// and do allow Requires predicates, e.g.: 742fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// 743fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>; 744fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>; 745fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount/// 746fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mountclass MnemonicAlias<string From, string To> { 747fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string FromMnemonic = From; 748fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string ToMnemonic = To; 749fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 750fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // Predicates - Predicates that must be true for this remapping to happen. 751b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount list<Predicate> Predicates = []; 752b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount} 753b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount 754b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount/// InstAlias - This defines an alternate assembly syntax that is allowed to 755b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount/// match an instruction that has a different (more canonical) assembly 756b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount/// representation. 757b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mountclass InstAlias<string Asm, dag Result, bit Emit = 0b1> { 758b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount string AsmString = Asm; // The .s format to match the instruction with. 759b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount dag ResultInst = Result; // The MCInst to generate. 760b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount bit EmitAlias = Emit; // Emit the alias instead of what's aliased. 761b89d5cc2c64112a0ff7e66e4dd3bb2114caed935George Mount 762fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // Predicates - Predicates that must be true for this to match. 763fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount list<Predicate> Predicates = []; 764fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount} 765fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 766fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount//===----------------------------------------------------------------------===// 767fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// AsmWriter - This class can be implemented by targets that need to customize 768fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// the format of the .s file writer. 769fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// 770fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax 771fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// on X86 for example). 772fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// 773fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mountclass AsmWriter { 774fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // AsmWriterClassName - This specifies the suffix to use for the asmwriter 775fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // class. Generated AsmWriter classes are always prefixed with the target 776fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // name. 777fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string AsmWriterClassName = "AsmPrinter"; 778fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 779fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // Variant - AsmWriters can be of multiple different variants. Variants are 780fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // used to support targets that need to emit assembly code in ways that are 781fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // mostly the same for different targets, but have minor differences in 782fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // syntax. If the asmstring contains {|} characters in them, this integer 783fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // will specify which alternative to use. For example "{x|y|z}" with Variant 7846e7fb60b93d3449d256282a9cc34ba3356add90eGeorge Mount // == 1, will expand to "y". 78548bd13c9cb2627847cf1f7707a084eb354e9c303George Mount int Variant = 0; 78648bd13c9cb2627847cf1f7707a084eb354e9c303George Mount 78748bd13c9cb2627847cf1f7707a084eb354e9c303George Mount 78848bd13c9cb2627847cf1f7707a084eb354e9c303George Mount // FirstOperandColumn/OperandSpacing - If the assembler syntax uses a columnar 78948bd13c9cb2627847cf1f7707a084eb354e9c303George Mount // layout, the asmwriter can actually generate output in this columns (in 79048bd13c9cb2627847cf1f7707a084eb354e9c303George Mount // verbose-asm mode). These two values indicate the width of the first column 79148bd13c9cb2627847cf1f7707a084eb354e9c303George Mount // (the "opcode" area) and the width to reserve for subsequent operands. When 79248bd13c9cb2627847cf1f7707a084eb354e9c303George Mount // verbose asm mode is enabled, operands will be indented to respect this. 79348bd13c9cb2627847cf1f7707a084eb354e9c303George Mount int FirstOperandColumn = -1; 79448bd13c9cb2627847cf1f7707a084eb354e9c303George Mount 79548bd13c9cb2627847cf1f7707a084eb354e9c303George Mount // OperandSpacing - Space between operand columns. 796fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount int OperandSpacing = -1; 797fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 79867d924341a1d0994ac68b3b7898d5576edd987b4George Mount // isMCAsmWriter - Is this assembly writer for an MC emitter? This controls 79967d924341a1d0994ac68b3b7898d5576edd987b4George Mount // generation of the printInstruction() method. For MC printers, it takes 80067d924341a1d0994ac68b3b7898d5576edd987b4George Mount // an MCInstr* operand, otherwise it takes a MachineInstr*. 80167d924341a1d0994ac68b3b7898d5576edd987b4George Mount bit isMCAsmWriter = 0; 80267d924341a1d0994ac68b3b7898d5576edd987b4George Mount} 80367d924341a1d0994ac68b3b7898d5576edd987b4George Mountdef DefaultAsmWriter : AsmWriter; 80467d924341a1d0994ac68b3b7898d5576edd987b4George Mount 80567d924341a1d0994ac68b3b7898d5576edd987b4George Mount 80667d924341a1d0994ac68b3b7898d5576edd987b4George Mount//===----------------------------------------------------------------------===// 80767d924341a1d0994ac68b3b7898d5576edd987b4George Mount// Target - This class contains the "global" target information 80867d924341a1d0994ac68b3b7898d5576edd987b4George Mount// 80967d924341a1d0994ac68b3b7898d5576edd987b4George Mountclass Target { 810c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // InstructionSet - Instruction set description for this target. 811c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount InstrInfo InstructionSet; 812c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 813c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // AssemblyParsers - The AsmParser instances available for this target. 814c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount list<AsmParser> AssemblyParsers = [DefaultAsmParser]; 815c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount 816c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount // AssemblyWriters - The AsmWriter instances available for this target. 817c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount list<AsmWriter> AssemblyWriters = [DefaultAsmWriter]; 818c93ca1617397aace8449f88d1a1e94ec704a2ef4George Mount} 81931a217290cf376d0573fc36e21c8940987485019George Mount 82031a217290cf376d0573fc36e21c8940987485019George Mount//===----------------------------------------------------------------------===// 82131a217290cf376d0573fc36e21c8940987485019George Mount// SubtargetFeature - A characteristic of the chip set. 82231a217290cf376d0573fc36e21c8940987485019George Mount// 82331a217290cf376d0573fc36e21c8940987485019George Mountclass SubtargetFeature<string n, string a, string v, string d, 82431a217290cf376d0573fc36e21c8940987485019George Mount list<SubtargetFeature> i = []> { 825dc21d3b2804c24fe29ec860796d11185901364c4George Mount // Name - Feature name. Used by command line (-mattr=) to determine the 82631a217290cf376d0573fc36e21c8940987485019George Mount // appropriate target chip. 82731a217290cf376d0573fc36e21c8940987485019George Mount // 82831a217290cf376d0573fc36e21c8940987485019George Mount string Name = n; 829800d72b0e05049e4a8f90ea96ec165fc975264ceGeorge Mount 830fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // Attribute - Attribute to be set by feature. 831fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // 832fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string Attribute = a; 8336e7fb60b93d3449d256282a9cc34ba3356add90eGeorge Mount 834fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // Value - Value the attribute to be set to by feature. 835fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // 8366e7fb60b93d3449d256282a9cc34ba3356add90eGeorge Mount string Value = v; 837fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 8386e7fb60b93d3449d256282a9cc34ba3356add90eGeorge Mount // Desc - Feature description. Used by command line (-mattr=) to display help 839fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // information. 840fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // 841fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string Desc = d; 842fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 843fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // Implies - Features that this feature implies are present. If one of those 844fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // features isn't set, then this one shouldn't be set either. 845fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // 846fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount list<SubtargetFeature> Implies = i; 847fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount} 848fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount 849fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount//===----------------------------------------------------------------------===// 8506e7fb60b93d3449d256282a9cc34ba3356add90eGeorge Mount// Processor chip sets - These values represent each of the chip sets supported 851fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// by the scheduler. Each Processor definition requires corresponding 852fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// instruction itineraries. 853fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount// 854fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mountclass Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f> { 855fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // Name - Chip set name. Used by command line (-mcpu=) to determine the 856fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // appropriate target chip. 857fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount // 858fe361d2113b8f3c54797d7bd720ca739328bd7aaGeorge Mount string Name = n; 859c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu 860c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // ProcItin - The scheduling information for the target processor. 861c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // 862c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu ProcessorItineraries ProcItin = pi; 863c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu 864c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu // Features - list of 865c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu list<SubtargetFeature> Features = f; 866c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu} 867c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu 86826c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount//===----------------------------------------------------------------------===// 86926c82b6ed1e8e7276fe2ca65c241fc4c4cac6d12George Mount// Pull in the common support for calling conventions. 870c18f4cc0f2dfb05b22c6187c5c2c2dead4f504a5Dake Gu// 87131a217290cf376d0573fc36e21c8940987485019George Mountinclude "llvm/Target/TargetCallingConv.td" 872 873//===----------------------------------------------------------------------===// 874// Pull in the common support for DAG isel generation. 875// 876include "llvm/Target/TargetSelectionDAG.td" 877