X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FCodeGenTarget.h;h=f5952bccf05f8f1ad1fc4a1ac1d3c4832972a831;hb=e14d2e210dc7fe28009f44818a057622a73322e4;hp=a0e631e1093faa52a0dfdb5b0ad34eb7b18a432d;hpb=6a91b18e5777f39e52e93221453abfa4553b6f93;p=oota-llvm.git diff --git a/utils/TableGen/CodeGenTarget.h b/utils/TableGen/CodeGenTarget.h index a0e631e1093..f5952bccf05 100644 --- a/utils/TableGen/CodeGenTarget.h +++ b/utils/TableGen/CodeGenTarget.h @@ -17,11 +17,11 @@ #ifndef CODEGEN_TARGET_H #define CODEGEN_TARGET_H -#include "llvm/Support/raw_ostream.h" #include "CodeGenRegisters.h" #include "CodeGenInstruction.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/ADT/DenseMap.h" #include -#include namespace llvm { @@ -62,7 +62,7 @@ std::string getQualifiedName(const Record *R); class CodeGenTarget { Record *TargetRec; - mutable std::map Instructions; + mutable DenseMap Instructions; mutable std::vector Registers; mutable std::vector RegisterClasses; mutable std::vector LegalValueTypes; @@ -185,25 +185,20 @@ public: return false; } - /// getInstructions - Return all of the instructions defined for this target. - /// private: - const std::map &getInstructions() const { + DenseMap &getInstructions() const { if (Instructions.empty()) ReadInstructions(); return Instructions; } - std::map &getInstructions() { - if (Instructions.empty()) ReadInstructions(); - return Instructions; - } - CodeGenInstruction &getInstruction(const std::string &Name) const { - const std::map &Insts = getInstructions(); - assert(Insts.count(Name) && "Not an instruction!"); - return const_cast(Insts.find(Name)->second); - } public: - CodeGenInstruction &getInstruction(const Record *InstRec) const; + CodeGenInstruction &getInstruction(const Record *InstRec) const { + if (Instructions.empty()) ReadInstructions(); + DenseMap::iterator I = + Instructions.find(InstRec); + assert(I != Instructions.end() && "Not an instruction"); + return *I->second; + } /// getInstructionsByEnumValue - Return all of the instructions defined by the /// target, ordered by their enum value.