2002-08-09 20:08:03 +00:00
|
|
|
//===-- llvm/CodeGen/InstrSelection.h --------------------------*- C++ -*--===//
|
|
|
|
//
|
|
|
|
// External interface to instruction selection.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_INSTR_SELECTION_H
|
|
|
|
#define LLVM_CODEGEN_INSTR_SELECTION_H
|
|
|
|
|
|
|
|
#include "llvm/Instruction.h"
|
2003-06-30 21:59:07 +00:00
|
|
|
|
2002-03-23 22:51:58 +00:00
|
|
|
class Function;
|
2001-07-21 12:39:03 +00:00
|
|
|
class InstrForest;
|
2001-07-22 04:40:02 +00:00
|
|
|
class MachineInstr;
|
|
|
|
class InstructionNode;
|
2001-07-23 03:09:03 +00:00
|
|
|
class TargetMachine;
|
2003-05-31 07:41:24 +00:00
|
|
|
class MachineCodeForInstruction;
|
2002-07-30 03:55:29 +00:00
|
|
|
class Pass;
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2002-08-09 20:08:03 +00:00
|
|
|
//===--------------------- Required Functions ---------------------------------
|
|
|
|
// Target-dependent functions that MUST be implemented for each target.
|
|
|
|
//
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
const unsigned MAX_INSTR_PER_VMINSTR = 8;
|
|
|
|
|
2002-03-18 03:20:46 +00:00
|
|
|
extern void GetInstructionsByRule (InstructionNode* subtreeRoot,
|
2001-07-21 12:39:03 +00:00
|
|
|
int ruleForNode,
|
|
|
|
short* nts,
|
2001-07-23 03:09:03 +00:00
|
|
|
TargetMachine &Target,
|
2002-06-25 20:22:25 +00:00
|
|
|
std::vector<MachineInstr*>& mvec);
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
extern bool ThisIsAChainRule (int eruleno);
|
|
|
|
|
|
|
|
|
2001-10-10 20:50:20 +00:00
|
|
|
//************************ Exported Functions ******************************/
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
2002-07-30 03:55:29 +00:00
|
|
|
// Function: createInstructionSelectionPass
|
2001-07-21 12:39:03 +00:00
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Entry point for instruction selection using BURG.
|
2002-07-30 03:55:29 +00:00
|
|
|
// Return a pass that performs machine dependant instruction selection.
|
2001-07-21 12:39:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2002-07-30 03:55:29 +00:00
|
|
|
Pass *createInstructionSelectionPass(TargetMachine &Target);
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
|
2001-10-10 20:50:20 +00:00
|
|
|
//************************ Exported Data Types *****************************/
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// class TmpInstruction
|
|
|
|
//
|
|
|
|
// This class represents temporary intermediate values
|
|
|
|
// used within the machine code for a VM instruction
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class TmpInstruction : public Instruction {
|
2002-02-03 07:07:16 +00:00
|
|
|
TmpInstruction(const TmpInstruction &TI)
|
|
|
|
: Instruction(TI.getType(), TI.getOpcode()) {
|
|
|
|
if (!TI.Operands.empty()) {
|
|
|
|
Operands.push_back(Use(TI.Operands[0], this));
|
|
|
|
if (TI.Operands.size() == 2)
|
|
|
|
Operands.push_back(Use(TI.Operands[1], this));
|
|
|
|
else
|
|
|
|
assert(0 && "Bad # operands to TmpInstruction!");
|
|
|
|
}
|
2001-07-21 12:39:03 +00:00
|
|
|
}
|
|
|
|
public:
|
2001-11-08 04:50:33 +00:00
|
|
|
// Constructor that uses the type of S1 as the type of the temporary.
|
|
|
|
// s1 must be a valid value. s2 may be NULL.
|
2003-05-31 07:41:24 +00:00
|
|
|
TmpInstruction(MachineCodeForInstruction& mcfi,
|
|
|
|
Value *s1, Value *s2 = 0, const std::string &name = "");
|
2001-11-08 04:50:33 +00:00
|
|
|
|
2002-02-03 07:07:16 +00:00
|
|
|
// Constructor that requires the type of the temporary to be specified.
|
2001-11-08 04:50:33 +00:00
|
|
|
// Both S1 and S2 may be NULL.
|
2003-05-31 07:41:24 +00:00
|
|
|
TmpInstruction(MachineCodeForInstruction& mcfi,
|
|
|
|
const Type *Ty, Value *s1 = 0, Value* s2 = 0,
|
2002-09-08 21:07:51 +00:00
|
|
|
const std::string &name = "");
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2003-05-31 07:41:24 +00:00
|
|
|
virtual Instruction *clone() const {
|
|
|
|
assert(0 && "Cannot clone TmpInstructions!");
|
|
|
|
return 0;
|
|
|
|
}
|
2001-07-21 12:39:03 +00:00
|
|
|
virtual const char *getOpcodeName() const {
|
2002-03-24 03:56:55 +00:00
|
|
|
return "TempValueForMachineInstr";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const TmpInstruction *) { return true; }
|
|
|
|
static inline bool classof(const Instruction *I) {
|
|
|
|
return (I->getOpcode() == Instruction::UserOp1);
|
|
|
|
}
|
|
|
|
static inline bool classof(const Value *V) {
|
|
|
|
return isa<Instruction>(V) && classof(cast<Instruction>(V));
|
2001-11-08 04:50:33 +00:00
|
|
|
}
|
2001-07-21 12:39:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|