[llvm-commits] [llvm] r55093 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h utils/TableGen/FastISelEmitter.cpp utils/TableGen/FastISelEmitter.h
Dan Gohman
gohman at apple.com
Wed Aug 20 17:19:05 PDT 2008
Author: djg
Date: Wed Aug 20 19:19:05 2008
New Revision: 55093
URL: http://llvm.org/viewvc/llvm-project?rev=55093&view=rev
Log:
Begin making more use of the FastISelEmitter class.
Modified:
llvm/trunk/include/llvm/CodeGen/FastISel.h
llvm/trunk/utils/TableGen/FastISelEmitter.cpp
llvm/trunk/utils/TableGen/FastISelEmitter.h
Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=55093&r1=55092&r2=55093&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/FastISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/FastISel.h Wed Aug 20 19:19:05 2008
@@ -120,6 +120,8 @@
unsigned Op0, unsigned Op1);
private:
+ unsigned createResultReg(const TargetRegisterClass *RC);
+
bool SelectBinaryOp(Instruction *I, ISD::NodeType ISDOpcode,
DenseMap<const Value*, unsigned> &ValueMap);
Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=55093&r1=55092&r2=55093&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Wed Aug 20 19:19:05 2008
@@ -150,24 +150,15 @@
void FastISelEmitter::run(std::ostream &OS) {
EmitSourceFileHeader("\"Fast\" Instruction Selector for the " +
- CGP.getTargetInfo().getName() + " target", OS);
-
- const CodeGenTarget &Target = CGP.getTargetInfo();
-
- // Get the namespace to insert instructions into. Make sure not to pick up
- // "TargetInstrInfo" by accidentally getting the namespace off the PHI
- // instruction or something.
- std::string InstNS = Target.getInstNamespace();
+ Target.getName() + " target", OS);
+ OS << "#include \"llvm/CodeGen/FastISel.h\"\n";
+ OS << "\n";
OS << "namespace llvm {\n";
- OS << "namespace " << InstNS << " {\n";
- OS << "class FastISel;\n";
- OS << "}\n";
- OS << "}\n";
+ OS << "\n";
+ OS << "namespace " << InstNS.substr(0, InstNS.size() - 2) << " {\n";
OS << "\n";
- if (!InstNS.empty()) InstNS += "::";
-
typedef std::map<MVT::SimpleValueType, InstructionMemo> TypeMap;
typedef std::map<std::string, TypeMap> OpcodeTypeMap;
typedef std::map<OperandsSignature, OpcodeTypeMap> OperandsOpcodeTypeMap;
@@ -245,13 +236,8 @@
}
}
- OS << "#include \"llvm/CodeGen/FastISel.h\"\n";
- OS << "\n";
- OS << "namespace llvm {\n";
- OS << "\n";
-
// Declare the target FastISel class.
- OS << "class " << InstNS << "FastISel : public llvm::FastISel {\n";
+ OS << "class FastISel : public llvm::FastISel {\n";
for (OperandsOpcodeTypeMap::const_iterator OI = SimplePatterns.begin(),
OE = SimplePatterns.end(); OI != OE; ++OI) {
const OperandsSignature &Operands = OI->first;
@@ -294,9 +280,8 @@
OS << "\n";
// Define the target FastISel creation function.
- OS << "llvm::FastISel *" << InstNS
- << "createFastISel(MachineFunction &mf) {\n";
- OS << " return new " << InstNS << "FastISel(mf);\n";
+ OS << "llvm::FastISel *createFastISel(MachineFunction &mf) {\n";
+ OS << " return new FastISel(mf);\n";
OS << "}\n";
OS << "\n";
@@ -320,7 +305,7 @@
MVT::SimpleValueType VT = TI->first;
const InstructionMemo &Memo = TI->second;
- OS << "unsigned " << InstNS << "FastISel::FastEmit_"
+ OS << "unsigned FastISel::FastEmit_"
<< getLegalCName(Opcode)
<< "_" << getLegalCName(getName(VT)) << "(";
Operands.PrintParameters(OS);
@@ -338,7 +323,7 @@
}
// Emit one function for the opcode that demultiplexes based on the type.
- OS << "unsigned " << InstNS << "FastISel::FastEmit_"
+ OS << "unsigned FastISel::FastEmit_"
<< getLegalCName(Opcode) << "(MVT::SimpleValueType VT";
if (!Operands.empty())
OS << ", ";
@@ -362,7 +347,7 @@
// Emit one function for the operand signature that demultiplexes based
// on opcode and type.
- OS << "unsigned " << InstNS << "FastISel::FastEmit_";
+ OS << "unsigned FastISel::FastEmit_";
Operands.PrintManglingSuffix(OS);
OS << "(MVT::SimpleValueType VT, ISD::NodeType Opcode";
if (!Operands.empty())
@@ -387,5 +372,16 @@
OS << "\n";
}
- OS << "}\n";
+ OS << "} // namespace X86\n";
+ OS << "\n";
+ OS << "} // namespace llvm\n";
+}
+
+FastISelEmitter::FastISelEmitter(RecordKeeper &R)
+ : Records(R),
+ CGP(R),
+ Target(CGP.getTargetInfo()),
+ InstNS(Target.getInstNamespace() + "::") {
+
+ assert(InstNS.size() > 2 && "Can't determine target-specific namespace!");
}
Modified: llvm/trunk/utils/TableGen/FastISelEmitter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.h?rev=55093&r1=55092&r2=55093&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/FastISelEmitter.h (original)
+++ llvm/trunk/utils/TableGen/FastISelEmitter.h Wed Aug 20 19:19:05 2008
@@ -19,14 +19,18 @@
namespace llvm {
+class CodeGenTarget;
+
/// FastISelEmitter - The top-level class which coordinates construction
/// and emission of the instruction selector.
///
class FastISelEmitter : public TableGenBackend {
RecordKeeper &Records;
CodeGenDAGPatterns CGP;
+ const CodeGenTarget &Target;
+ const std::string InstNS;
public:
- explicit FastISelEmitter(RecordKeeper &R) : Records(R), CGP(R) {}
+ explicit FastISelEmitter(RecordKeeper &R);
// run - Output the isel, returning true on failure.
void run(std::ostream &OS);
More information about the llvm-commits
mailing list