CodeGenInstruction.h revision c4af4638dfdab0dc3b6257276cfad2ee45053060
1ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner//===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===// 23da94aec4d429b2ba0f65fa040c33650cade196bMisha Brukman// 3ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner// The LLVM Compiler Infrastructure 4ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner// 53060910e290949a9ac5eda8726d030790c4d60ffChris Lattner// This file is distributed under the University of Illinois Open Source 63060910e290949a9ac5eda8726d030790c4d60ffChris Lattner// License. See LICENSE.TXT for details. 73da94aec4d429b2ba0f65fa040c33650cade196bMisha Brukman// 8ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner//===----------------------------------------------------------------------===// 9ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner// 10ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner// This file defines a wrapper class for the 'Instruction' TableGen class. 11ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner// 12ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner//===----------------------------------------------------------------------===// 13ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner 14ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#ifndef CODEGEN_INSTRUCTION_H 15ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#define CODEGEN_INSTRUCTION_H 16ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner 1787c5905e0b6f551e21c9a96f1b6418920d908210Chris Lattner#include "llvm/CodeGen/ValueTypes.h" 18225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner#include "llvm/ADT/StringRef.h" 19ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#include <string> 20ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#include <vector> 21ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#include <utility> 22ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner 23ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattnernamespace llvm { 24ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner class Record; 2565303d6bd777b76735ef179870678a1d14671c54Chris Lattner class DagInit; 269414ae52911f1d62cabd5108e0381b9d17476157Chris Lattner class CodeGenTarget; 274d43d0fd996a01c2cd21fd51082bc1bba783ef3cChris Lattner class StringRef; 28c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 29c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner class CGIOperandList { 30d41b30def3181bce4bf87e8bde664d15663165d0Jeff Cohen public: 31a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner class ConstraintInfo { 32a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner enum { None, EarlyClobber, Tied } Kind; 33a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner unsigned OtherTiedOperand; 34a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner public: 35a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner ConstraintInfo() : Kind(None) {} 36c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 37a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner static ConstraintInfo getEarlyClobber() { 38a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner ConstraintInfo I; 39a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner I.Kind = EarlyClobber; 40e555c9f4a54fd854af13f117fc0650ada3df3d24Chris Lattner I.OtherTiedOperand = 0; 41a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner return I; 42a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner } 43c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 44a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner static ConstraintInfo getTied(unsigned Op) { 45a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner ConstraintInfo I; 46a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner I.Kind = Tied; 47a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner I.OtherTiedOperand = Op; 48a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner return I; 49a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner } 50c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 51a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner bool isNone() const { return Kind == None; } 52a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner bool isEarlyClobber() const { return Kind == EarlyClobber; } 53a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner bool isTied() const { return Kind == Tied; } 54c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 55a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner unsigned getTiedOperand() const { 56a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner assert(isTied()); 57a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner return OtherTiedOperand; 58a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner } 59a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner }; 609ed2cee1057e2df3a4305b9c818aa577c8504f59Jim Grosbach 61cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// OperandInfo - The information we keep track of for each operand in the 62cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// operand list for a tablegen instruction. 6387c5905e0b6f551e21c9a96f1b6418920d908210Chris Lattner struct OperandInfo { 64cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// Rec - The definition this operand is declared as. 650e384b66a781fc0ff005f475a7ab151afa054fb0Chris Lattner /// 6687c5905e0b6f551e21c9a96f1b6418920d908210Chris Lattner Record *Rec; 67c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 68cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// Name - If this operand was assigned a symbolic name, this is it, 69cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// otherwise, it's empty. 7087c5905e0b6f551e21c9a96f1b6418920d908210Chris Lattner std::string Name; 71c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 72cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// PrinterMethodName - The method used to print operands of this type in 73cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// the asmprinter. 74cf03da0ce913267c4971534e8792297e06535a4eChris Lattner std::string PrinterMethodName; 75c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 765013f7469ec44adba127de65517e699180ee532fJim Grosbach /// EncoderMethodName - The method used to get the machine operand value 775013f7469ec44adba127de65517e699180ee532fJim Grosbach /// for binary encoding. "getMachineOpValue" by default. 785013f7469ec44adba127de65517e699180ee532fJim Grosbach std::string EncoderMethodName; 79c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 80cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// MIOperandNo - Currently (this is meant to be phased out), some logical 81cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// operands correspond to multiple MachineInstr operands. In the X86 82cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// target for example, one address operand is represented as 4 83cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// MachineOperands. Because of this, the operand number in the 84cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// OperandList may not match the MachineInstr operand num. Until it 85cf03da0ce913267c4971534e8792297e06535a4eChris Lattner /// does, this contains the MI operand index of this operand. 86cf03da0ce913267c4971534e8792297e06535a4eChris Lattner unsigned MIOperandNo; 87cfbf96aa9c3bd317548f72e022ba28a40353f95aChris Lattner unsigned MINumOperands; // The number of operands. 88c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 89f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner /// DoNotEncode - Bools are set to true in this vector for each operand in 90f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner /// the DisableEncoding list. These should not be emitted by the code 91f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner /// emitter. 92f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner std::vector<bool> DoNotEncode; 93c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 948ef9d16d3913db11c89fc2d14899e153bdbdc91bNate Begeman /// MIOperandInfo - Default MI operand type. Note an operand may be made 958ef9d16d3913db11c89fc2d14899e153bdbdc91bNate Begeman /// up of multiple MI operands. 9665303d6bd777b76735ef179870678a1d14671c54Chris Lattner DagInit *MIOperandInfo; 97c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 980bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// Constraint info for this operand. This operand can have pieces, so we 990bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// track constraint info for each. 100a7d479c7bd9723cabdd7c9e1e9a1e6e482f78e7eChris Lattner std::vector<ConstraintInfo> Constraints; 101c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 1029ed2cee1057e2df3a4305b9c818aa577c8504f59Jim Grosbach OperandInfo(Record *R, const std::string &N, const std::string &PMN, 1035013f7469ec44adba127de65517e699180ee532fJim Grosbach const std::string &EMN, unsigned MION, unsigned MINO, 1045013f7469ec44adba127de65517e699180ee532fJim Grosbach DagInit *MIOI) 105c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN), 1069b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner MIOperandNo(MION), MINumOperands(MINO), MIOperandInfo(MIOI) {} 1079b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner 1089b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner 1099b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner /// getTiedOperand - If this operand is tied to another one, return the 1109b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner /// other operand number. Otherwise, return -1. 1119b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner int getTiedRegister() const { 1129b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner for (unsigned j = 0, e = Constraints.size(); j != e; ++j) { 1139b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner const CGIOperandList::ConstraintInfo &CI = Constraints[j]; 1149b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner if (CI.isTied()) return CI.getTiedOperand(); 1159b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner } 1169b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner return -1; 1179b0d4bfca0f23d39f5f2aef6b6740267a26ee17cChris Lattner } 11887c5905e0b6f551e21c9a96f1b6418920d908210Chris Lattner }; 119c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 120c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner CGIOperandList(Record *D); 121c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 122c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner Record *TheDef; // The actual record containing this OperandList. 1233da94aec4d429b2ba0f65fa040c33650cade196bMisha Brukman 124cedef1ccf0d53693b5e62d524e7ba6b2122231c7Chris Lattner /// NumDefs - Number of def operands declared, this is the number of 125cedef1ccf0d53693b5e62d524e7ba6b2122231c7Chris Lattner /// elements in the instruction's (outs) list. 12664d80e3387f328d21cd9cc06464b5de7861e3f27Evan Cheng /// 12764d80e3387f328d21cd9cc06464b5de7861e3f27Evan Cheng unsigned NumDefs; 128c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 129ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner /// OperandList - The list of declared operands, along with their declared 130ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner /// type (which is a record). 13187c5905e0b6f551e21c9a96f1b6418920d908210Chris Lattner std::vector<OperandInfo> OperandList; 132c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 133c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner // Information gleaned from the operand list. 1345127ce09a4e4379f971280fab461a5f03befddbcEvan Cheng bool isPredicable; 13588cc092ca5bd79480205ee7b01aa39c13f3e35d7Evan Cheng bool hasOptionalDef; 136c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isVariadic; 137c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 138c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner // Provide transparent accessors to the operand list. 139c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner unsigned size() const { return OperandList.size(); } 140c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner const OperandInfo &operator[](unsigned i) const { return OperandList[i]; } 141c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner OperandInfo &operator[](unsigned i) { return OperandList[i]; } 142c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner OperandInfo &back() { return OperandList.back(); } 143c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner const OperandInfo &back() const { return OperandList.back(); } 144c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 145c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 146c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// getOperandNamed - Return the index of the operand with the specified 147c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// non-empty name. If the instruction does not have an operand with the 148c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// specified name, throw an exception. 149c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner unsigned getOperandNamed(StringRef Name) const; 150c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 151c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// hasOperandNamed - Query whether the instruction has an operand of the 152c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// given name. If so, return true and set OpIdx to the index of the 153c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// operand. Otherwise, return false. 154c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool hasOperandNamed(StringRef Name, unsigned &OpIdx) const; 155c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 1560bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// ParseOperandName - Parse an operand name like "$foo" or "$foo.bar", 1570bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// where $foo is a whole operand and $foo.bar refers to a suboperand. 1580bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// This throws an exception if the name is invalid. If AllowWholeOp is 1590bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// true, references to operands with suboperands are allowed, otherwise 1600bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// not. 1610bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner std::pair<unsigned,unsigned> ParseOperandName(const std::string &Op, 1620bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner bool AllowWholeOp = true); 163c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 1640bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// getFlattenedOperandNumber - Flatten a operand/suboperand pair into a 1650bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner /// flat machineinstr operand #. 1660bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner unsigned getFlattenedOperandNumber(std::pair<unsigned,unsigned> Op) const { 1670bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner return OperandList[Op.first].MIOperandNo + Op.second; 1680bb75004ff6c0ad26de7610cb873f81ea26fd6caChris Lattner } 169c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 170f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner /// getSubOperandNumber - Unflatten a operand number into an 171f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner /// operand/suboperand pair. 172f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner std::pair<unsigned,unsigned> getSubOperandNumber(unsigned Op) const { 173f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner for (unsigned i = 0; ; ++i) { 174f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner assert(i < OperandList.size() && "Invalid flat operand #"); 175f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op) 176f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner return std::make_pair(i, Op-OperandList[i].MIOperandNo); 177f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner } 178f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner } 179c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 180c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 181f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner /// isFlatOperandNotEmitted - Return true if the specified flat operand # 182f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner /// should not be emitted with the code emitter. 183f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner bool isFlatOperandNotEmitted(unsigned FlatOpNo) const { 184f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner std::pair<unsigned,unsigned> Op = getSubOperandNumber(FlatOpNo); 185f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner if (OperandList[Op.first].DoNotEncode.size() > Op.second) 186f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner return OperandList[Op.first].DoNotEncode[Op.second]; 187f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner return false; 188f64f9a4b75d07819866bfcf918b922a76d3e1600Chris Lattner } 189c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 190c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner void ProcessDisableEncoding(std::string Value); 191c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner }; 192c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 193ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner 194c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner class CodeGenInstruction { 195c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner public: 196c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner Record *TheDef; // The actual record defining this instruction. 197c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner std::string Namespace; // The namespace the instruction is in. 19887c5905e0b6f551e21c9a96f1b6418920d908210Chris Lattner 199c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// AsmString - The format string used to emit a .s file for the 200c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// instruction. 201c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner std::string AsmString; 2029ed2cee1057e2df3a4305b9c818aa577c8504f59Jim Grosbach 203c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// Operands - This is information about the (ins) and (outs) list specified 204c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// to the instruction. 205c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner CGIOperandList Operands; 206c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 207c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// ImplicitDefs/ImplicitUses - These are lists of registers that are 208c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner /// implicitly defined and used by the instruction. 209c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner std::vector<Record*> ImplicitDefs, ImplicitUses; 210c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 211c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner // Various boolean values we track for the instruction. 212c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isReturn; 213c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isBranch; 214c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isIndirectBranch; 215c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isCompare; 216c4af4638dfdab0dc3b6257276cfad2ee45053060Evan Cheng bool isMoveImm; 217c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isBarrier; 218c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isCall; 219c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool canFoldAsLoad; 220c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool mayLoad, mayStore; 221c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isPredicable; 222c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isConvertibleToThreeAddress; 223c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isCommutable; 224c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isTerminator; 225c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isReMaterializable; 226c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool hasDelaySlot; 227c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool usesCustomInserter; 228c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool hasCtrlDep; 229c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isNotDuplicable; 230c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool hasSideEffects; 231c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool neverHasSideEffects; 232c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool isAsCheapAsAMove; 233c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool hasExtraSrcRegAllocReq; 234c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner bool hasExtraDefRegAllocReq; 235c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 236c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner 237c240bb0ede0541426254d0e0dc81d891beda4b22Chris Lattner CodeGenInstruction(Record *R); 23801855071e24e0e3e75306b82267d3ad0b13a0c15Jim Grosbach 2399414ae52911f1d62cabd5108e0381b9d17476157Chris Lattner /// HasOneImplicitDefWithKnownVT - If the instruction has at least one 2409414ae52911f1d62cabd5108e0381b9d17476157Chris Lattner /// implicit def and it has a known VT, return the VT, otherwise return 2419414ae52911f1d62cabd5108e0381b9d17476157Chris Lattner /// MVT::Other. 2429ed2cee1057e2df3a4305b9c818aa577c8504f59Jim Grosbach MVT::SimpleValueType 2439414ae52911f1d62cabd5108e0381b9d17476157Chris Lattner HasOneImplicitDefWithKnownVT(const CodeGenTarget &TargetInfo) const; 2444d43d0fd996a01c2cd21fd51082bc1bba783ef3cChris Lattner 2454d43d0fd996a01c2cd21fd51082bc1bba783ef3cChris Lattner 2464d43d0fd996a01c2cd21fd51082bc1bba783ef3cChris Lattner /// FlattenAsmStringVariants - Flatten the specified AsmString to only 2474d43d0fd996a01c2cd21fd51082bc1bba783ef3cChris Lattner /// include text from the specified variant, returning the new string. 2484d43d0fd996a01c2cd21fd51082bc1bba783ef3cChris Lattner static std::string FlattenAsmStringVariants(StringRef AsmString, 2494d43d0fd996a01c2cd21fd51082bc1bba783ef3cChris Lattner unsigned Variant); 250ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner }; 251c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner 252c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner 253c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner /// CodeGenInstAlias - This represents an InstAlias definition. 254c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner class CodeGenInstAlias { 255c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner public: 256c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner Record *TheDef; // The actual record defining this InstAlias. 257c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner 258c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner /// AsmString - The format string used to emit a .s file for the 259c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner /// instruction. 260c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner std::string AsmString; 261c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner 262b501d4f673c0db267a76800339f9943f2ce6fe33Chris Lattner /// Result - The result instruction. 263b501d4f673c0db267a76800339f9943f2ce6fe33Chris Lattner DagInit *Result; 264b501d4f673c0db267a76800339f9943f2ce6fe33Chris Lattner 265225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner /// ResultInst - The instruction generated by the alias (decoded from 266225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner /// Result). 267225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner CodeGenInstruction *ResultInst; 268225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner 269225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner 270225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner struct ResultOperand { 27198c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner private: 272225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner StringRef Name; 273225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner Record *R; 274225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner 27598c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner int64_t Imm; 27698c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner public: 27798c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner enum { 27898c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner K_Record, 27990fd797dc739319347861d4f3984bc8952ae9a29Chris Lattner K_Imm, 28090fd797dc739319347861d4f3984bc8952ae9a29Chris Lattner K_Reg 28198c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner } Kind; 28298c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner 28398c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner ResultOperand(StringRef N, Record *r) : Name(N), R(r), Kind(K_Record) {} 28498c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner ResultOperand(int64_t I) : Imm(I), Kind(K_Imm) {} 28590fd797dc739319347861d4f3984bc8952ae9a29Chris Lattner ResultOperand(Record *r) : R(r), Kind(K_Reg) {} 28698c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner 28798c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner bool isRecord() const { return Kind == K_Record; } 28898c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner bool isImm() const { return Kind == K_Imm; } 28990fd797dc739319347861d4f3984bc8952ae9a29Chris Lattner bool isReg() const { return Kind == K_Reg; } 29098c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner 29198c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner StringRef getName() const { assert(isRecord()); return Name; } 29298c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner Record *getRecord() const { assert(isRecord()); return R; } 29398c870f87b7f0c996a9ba67003d88d434d6dbcd0Chris Lattner int64_t getImm() const { assert(isImm()); return Imm; } 29490fd797dc739319347861d4f3984bc8952ae9a29Chris Lattner Record *getRegister() const { assert(isReg()); return R; } 295225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner }; 296225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner 297225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner /// ResultOperands - The decoded operands for the result instruction. 298225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner std::vector<ResultOperand> ResultOperands; 299225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner 300225549f775db61c5dba10e14758f4b43c53ef593Chris Lattner CodeGenInstAlias(Record *R, CodeGenTarget &T); 3015bde7345980587284bda6d42a68cdb151fbf5d6bChris Lattner 3025bde7345980587284bda6d42a68cdb151fbf5d6bChris Lattner /// getResultInstOperandIndexForResultOperandIndex - Given an index into the 3035bde7345980587284bda6d42a68cdb151fbf5d6bChris Lattner /// ResultOperands array, translate it to a valid index in ResultInst's 3045bde7345980587284bda6d42a68cdb151fbf5d6bChris Lattner /// operand list. 3055bde7345980587284bda6d42a68cdb151fbf5d6bChris Lattner unsigned getResultInstOperandIndexForResultOperandIndex(unsigned i) const; 306c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner }; 307c76e80ded753b78a72be0db40fcdba543435d818Chris Lattner} 308ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner 309ec3524064c57fbc2c5976ca301bbaadc94006d07Chris Lattner#endif 310