Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 1 | //===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===// |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines a wrapper class for the 'Instruction' TableGen class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef CODEGEN_INSTRUCTION_H |
| 15 | #define CODEGEN_INSTRUCTION_H |
| 16 | |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/ValueTypes.h" |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 18 | #include <string> |
| 19 | #include <vector> |
| 20 | #include <utility> |
| 21 | |
| 22 | namespace llvm { |
| 23 | class Record; |
| 24 | |
| 25 | struct CodeGenInstruction { |
| 26 | Record *TheDef; // The actual record defining this instruction. |
| 27 | std::string Name; // Contents of the 'Name' field. |
| 28 | std::string Namespace; // The namespace the instruction is in. |
| 29 | |
| 30 | /// AsmString - The format string used to emit a .s file for the |
| 31 | /// instruction. |
| 32 | std::string AsmString; |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 33 | |
Chris Lattner | cf03da0 | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 34 | /// OperandInfo - The information we keep track of for each operand in the |
| 35 | /// operand list for a tablegen instruction. |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 36 | struct OperandInfo { |
Chris Lattner | cf03da0 | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 37 | /// Rec - The definition this operand is declared as. |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 38 | Record *Rec; |
Chris Lattner | cf03da0 | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 39 | |
| 40 | /// Ty - The MachineValueType of the operand. |
| 41 | /// |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 42 | MVT::ValueType Ty; |
Chris Lattner | cf03da0 | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 43 | |
| 44 | /// Name - If this operand was assigned a symbolic name, this is it, |
| 45 | /// otherwise, it's empty. |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 46 | std::string Name; |
Chris Lattner | cf03da0 | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 47 | |
| 48 | /// PrinterMethodName - The method used to print operands of this type in |
| 49 | /// the asmprinter. |
| 50 | std::string PrinterMethodName; |
| 51 | |
| 52 | /// MIOperandNo - Currently (this is meant to be phased out), some logical |
| 53 | /// operands correspond to multiple MachineInstr operands. In the X86 |
| 54 | /// target for example, one address operand is represented as 4 |
| 55 | /// MachineOperands. Because of this, the operand number in the |
| 56 | /// OperandList may not match the MachineInstr operand num. Until it |
| 57 | /// does, this contains the MI operand index of this operand. |
| 58 | unsigned MIOperandNo; |
Chris Lattner | cfbf96a | 2005-08-18 23:38:41 +0000 | [diff] [blame^] | 59 | unsigned MINumOperands; // The number of operands. |
Chris Lattner | cf03da0 | 2004-08-11 02:22:39 +0000 | [diff] [blame] | 60 | |
| 61 | OperandInfo(Record *R, MVT::ValueType T, const std::string &N, |
Chris Lattner | cfbf96a | 2005-08-18 23:38:41 +0000 | [diff] [blame^] | 62 | const std::string &PMN, unsigned MION, unsigned MINO) |
| 63 | : Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION), |
| 64 | MINumOperands(MINO) {} |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 65 | }; |
Misha Brukman | 3da94ae | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 66 | |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 67 | /// OperandList - The list of declared operands, along with their declared |
| 68 | /// type (which is a record). |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 69 | std::vector<OperandInfo> OperandList; |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 70 | |
| 71 | // Various boolean values we track for the instruction. |
| 72 | bool isReturn; |
| 73 | bool isBranch; |
| 74 | bool isBarrier; |
| 75 | bool isCall; |
Nate Begeman | cdd66b5 | 2004-09-28 21:01:45 +0000 | [diff] [blame] | 76 | bool isLoad; |
| 77 | bool isStore; |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 78 | bool isTwoAddress; |
Chris Lattner | aad75aa | 2005-01-02 02:29:04 +0000 | [diff] [blame] | 79 | bool isConvertibleToThreeAddress; |
| 80 | bool isCommutable; |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 81 | bool isTerminator; |
Chris Lattner | 5b71d3a | 2004-09-28 18:38:01 +0000 | [diff] [blame] | 82 | bool hasDelaySlot; |
Chris Lattner | cfbf96a | 2005-08-18 23:38:41 +0000 | [diff] [blame^] | 83 | bool hasVariableNumberOfOperands; |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 84 | |
Chris Lattner | 175580c | 2004-08-14 22:50:53 +0000 | [diff] [blame] | 85 | CodeGenInstruction(Record *R, const std::string &AsmStr); |
Chris Lattner | 87c5905 | 2004-08-01 07:42:39 +0000 | [diff] [blame] | 86 | |
| 87 | /// getOperandNamed - Return the index of the operand with the specified |
| 88 | /// non-empty name. If the instruction does not have an operand with the |
| 89 | /// specified name, throw an exception. |
| 90 | unsigned getOperandNamed(const std::string &Name) const; |
Chris Lattner | ec35240 | 2004-08-01 05:04:00 +0000 | [diff] [blame] | 91 | }; |
| 92 | } |
| 93 | |
| 94 | #endif |