CodeGenInstruction.h [plain text]
#ifndef CODEGEN_INSTRUCTION_H
#define CODEGEN_INSTRUCTION_H
#include "llvm/CodeGen/ValueTypes.h"
#include <string>
#include <vector>
#include <utility>
namespace llvm {
class Record;
class DagInit;
class CodeGenInstruction {
public:
Record *TheDef; std::string Namespace;
std::string AsmString;
class ConstraintInfo {
enum { None, EarlyClobber, Tied } Kind;
unsigned OtherTiedOperand;
public:
ConstraintInfo() : Kind(None) {}
static ConstraintInfo getEarlyClobber() {
ConstraintInfo I;
I.Kind = EarlyClobber;
I.OtherTiedOperand = 0;
return I;
}
static ConstraintInfo getTied(unsigned Op) {
ConstraintInfo I;
I.Kind = Tied;
I.OtherTiedOperand = Op;
return I;
}
bool isNone() const { return Kind == None; }
bool isEarlyClobber() const { return Kind == EarlyClobber; }
bool isTied() const { return Kind == Tied; }
unsigned getTiedOperand() const {
assert(isTied());
return OtherTiedOperand;
}
};
struct OperandInfo {
Record *Rec;
std::string Name;
std::string PrinterMethodName;
unsigned MIOperandNo;
unsigned MINumOperands;
std::vector<bool> DoNotEncode;
DagInit *MIOperandInfo;
std::vector<ConstraintInfo> Constraints;
OperandInfo(Record *R, const std::string &N, const std::string &PMN,
unsigned MION, unsigned MINO, DagInit *MIOI)
: Rec(R), Name(N), PrinterMethodName(PMN), MIOperandNo(MION),
MINumOperands(MINO), MIOperandInfo(MIOI) {}
};
unsigned NumDefs;
std::vector<OperandInfo> OperandList;
bool isReturn;
bool isBranch;
bool isIndirectBranch;
bool isBarrier;
bool isCall;
bool canFoldAsLoad;
bool mayLoad, mayStore;
bool isPredicable;
bool isConvertibleToThreeAddress;
bool isCommutable;
bool isTerminator;
bool isReMaterializable;
bool hasDelaySlot;
bool usesCustomInserter;
bool isVariadic;
bool hasCtrlDep;
bool isNotDuplicable;
bool hasOptionalDef;
bool hasSideEffects;
bool neverHasSideEffects;
bool isAsCheapAsAMove;
bool hasExtraSrcRegAllocReq;
bool hasExtraDefRegAllocReq;
std::pair<unsigned,unsigned> ParseOperandName(const std::string &Op,
bool AllowWholeOp = true);
unsigned getFlattenedOperandNumber(std::pair<unsigned,unsigned> Op) const {
return OperandList[Op.first].MIOperandNo + Op.second;
}
std::pair<unsigned,unsigned> getSubOperandNumber(unsigned Op) const {
for (unsigned i = 0; ; ++i) {
assert(i < OperandList.size() && "Invalid flat operand #");
if (OperandList[i].MIOperandNo+OperandList[i].MINumOperands > Op)
return std::make_pair(i, Op-OperandList[i].MIOperandNo);
}
}
bool isFlatOperandNotEmitted(unsigned FlatOpNo) const {
std::pair<unsigned,unsigned> Op = getSubOperandNumber(FlatOpNo);
if (OperandList[Op.first].DoNotEncode.size() > Op.second)
return OperandList[Op.first].DoNotEncode[Op.second];
return false;
}
CodeGenInstruction(Record *R, const std::string &AsmStr);
unsigned getOperandNamed(const std::string &Name) const;
};
}
#endif