CodeGenInstruction.h revision 87c5905e0b6f551e21c9a96f1b6418920d908210
1//===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===// 2// 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. 7// 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 17#include "llvm/CodeGen/ValueTypes.h" 18#include <string> 19#include <vector> 20#include <utility> 21 22namespace 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; 33 34 /// OperandInfo - For each operand declared in the OperandList of the 35 /// instruction, keep track of its record (which specifies the class of the 36 /// operand), its type, and the name given to the operand, if any. 37 struct OperandInfo { 38 Record *Rec; 39 MVT::ValueType Ty; 40 std::string Name; 41 OperandInfo(Record *R, MVT::ValueType T, const std::string &N) 42 : Rec(R), Ty(T), Name(N) {} 43 }; 44 45 /// OperandList - The list of declared operands, along with their declared 46 /// type (which is a record). 47 std::vector<OperandInfo> OperandList; 48 49 // Various boolean values we track for the instruction. 50 bool isReturn; 51 bool isBranch; 52 bool isBarrier; 53 bool isCall; 54 bool isTwoAddress; 55 bool isTerminator; 56 57 CodeGenInstruction(Record *R); 58 59 /// getOperandNamed - Return the index of the operand with the specified 60 /// non-empty name. If the instruction does not have an operand with the 61 /// specified name, throw an exception. 62 unsigned getOperandNamed(const std::string &Name) const; 63 }; 64} 65 66#endif 67