blob: 5269cc76e2b9d9de0724fdbaa493c4afbdc442dd [file] [log] [blame]
Chris Lattnerec352402004-08-01 05:04:00 +00001//===- 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
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
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 };
Chris Lattnerec352402004-08-01 05:04:00 +000044
45 /// OperandList - The list of declared operands, along with their declared
46 /// type (which is a record).
Chris Lattner87c59052004-08-01 07:42:39 +000047 std::vector<OperandInfo> OperandList;
Chris Lattnerec352402004-08-01 05:04:00 +000048
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);
Chris Lattner87c59052004-08-01 07:42:39 +000058
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;
Chris Lattnerec352402004-08-01 05:04:00 +000063 };
64}
65
66#endif