blob: 3b3babf592ce641adebd99547f38249f76962a40 [file] [log] [blame]
Chris Lattnerec352402004-08-01 05:04:00 +00001//===- CodeGenInstruction.h - Instruction Class Wrapper ---------*- C++ -*-===//
Misha Brukman3da94ae2005-04-22 00:00:37 +00002//
Chris Lattnerec352402004-08-01 05:04:00 +00003// 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 Brukman3da94ae2005-04-22 00:00:37 +00007//
Chris Lattnerec352402004-08-01 05:04:00 +00008//===----------------------------------------------------------------------===//
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 Lattner87c59052004-08-01 07:42:39 +000017#include "llvm/CodeGen/ValueTypes.h"
Chris Lattnerec352402004-08-01 05:04:00 +000018#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;
Chris Lattner87c59052004-08-01 07:42:39 +000033
Chris Lattnercf03da02004-08-11 02:22:39 +000034 /// OperandInfo - The information we keep track of for each operand in the
35 /// operand list for a tablegen instruction.
Chris Lattner87c59052004-08-01 07:42:39 +000036 struct OperandInfo {
Chris Lattnercf03da02004-08-11 02:22:39 +000037 /// Rec - The definition this operand is declared as.
Chris Lattner87c59052004-08-01 07:42:39 +000038 Record *Rec;
Chris Lattnercf03da02004-08-11 02:22:39 +000039
40 /// Ty - The MachineValueType of the operand.
41 ///
Chris Lattner87c59052004-08-01 07:42:39 +000042 MVT::ValueType Ty;
Chris Lattnercf03da02004-08-11 02:22:39 +000043
44 /// Name - If this operand was assigned a symbolic name, this is it,
45 /// otherwise, it's empty.
Chris Lattner87c59052004-08-01 07:42:39 +000046 std::string Name;
Chris Lattnercf03da02004-08-11 02:22:39 +000047
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;
59
60 OperandInfo(Record *R, MVT::ValueType T, const std::string &N,
61 const std::string &PMN, unsigned MION)
62 : Rec(R), Ty(T), Name(N), PrinterMethodName(PMN), MIOperandNo(MION) {}
Chris Lattner87c59052004-08-01 07:42:39 +000063 };
Misha Brukman3da94ae2005-04-22 00:00:37 +000064
Chris Lattnerec352402004-08-01 05:04:00 +000065 /// OperandList - The list of declared operands, along with their declared
66 /// type (which is a record).
Chris Lattner87c59052004-08-01 07:42:39 +000067 std::vector<OperandInfo> OperandList;
Chris Lattnerec352402004-08-01 05:04:00 +000068
69 // Various boolean values we track for the instruction.
70 bool isReturn;
71 bool isBranch;
72 bool isBarrier;
73 bool isCall;
Nate Begemancdd66b52004-09-28 21:01:45 +000074 bool isLoad;
75 bool isStore;
Chris Lattnerec352402004-08-01 05:04:00 +000076 bool isTwoAddress;
Chris Lattneraad75aa2005-01-02 02:29:04 +000077 bool isConvertibleToThreeAddress;
78 bool isCommutable;
Chris Lattnerec352402004-08-01 05:04:00 +000079 bool isTerminator;
Chris Lattner5b71d3a2004-09-28 18:38:01 +000080 bool hasDelaySlot;
Chris Lattnerec352402004-08-01 05:04:00 +000081
Chris Lattner175580c2004-08-14 22:50:53 +000082 CodeGenInstruction(Record *R, const std::string &AsmStr);
Chris Lattner87c59052004-08-01 07:42:39 +000083
84 /// getOperandNamed - Return the index of the operand with the specified
85 /// non-empty name. If the instruction does not have an operand with the
86 /// specified name, throw an exception.
87 unsigned getOperandNamed(const std::string &Name) const;
Chris Lattnerec352402004-08-01 05:04:00 +000088 };
89}
90
91#endif