Clean up TargetIntrinsicInfo API. Add pure virtual methods.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84192 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2009-10-15 18:49:26 +00:00
parent 20312d0bb8
commit 0383606b65
2 changed files with 20 additions and 26 deletions

View File

@ -25,35 +25,21 @@ class Type;
/// TargetIntrinsicInfo - Interface to description of machine instruction set /// TargetIntrinsicInfo - Interface to description of machine instruction set
/// ///
class TargetIntrinsicInfo { class TargetIntrinsicInfo {
const char **Intrinsics; // Raw array to allow static init'n
unsigned NumIntrinsics; // Number of entries in the desc array
TargetIntrinsicInfo(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT TargetIntrinsicInfo(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT
void operator=(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT void operator=(const TargetIntrinsicInfo &); // DO NOT IMPLEMENT
public: public:
TargetIntrinsicInfo(const char **desc, unsigned num); TargetIntrinsicInfo();
virtual ~TargetIntrinsicInfo(); virtual ~TargetIntrinsicInfo();
unsigned getNumIntrinsics() const { return NumIntrinsics; } /// Return the name of a target intrinsic, e.g. "llvm.bfin.ssync".
virtual const char *getName(unsigned IntrID) const =0;
virtual Function *getDeclaration(Module *M, const char *BuiltinName) const { /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
return 0; /// names.
} virtual unsigned lookupName(const char *Name, unsigned Len) const =0;
// Returns the Function declaration for intrinsic BuiltinName. If the /// Return the target intrinsic ID of a function, or 0.
// intrinsic can be overloaded, uses Tys to return the correct function. virtual unsigned getIntrinsicID(Function *F) const;
virtual Function *getDeclaration(Module *M, const char *BuiltinName,
const Type **Tys, unsigned numTys) const {
return 0;
}
// Returns true if the Builtin can be overloaded.
virtual bool isOverloaded(Module *M, const char *BuiltinName) const {
return false;
}
virtual unsigned getIntrinsicID(Function *F) const { return 0; }
}; };
} // End llvm namespace } // End llvm namespace

View File

@ -12,11 +12,19 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/Target/TargetIntrinsicInfo.h" #include "llvm/Target/TargetIntrinsicInfo.h"
#include "llvm/Function.h"
#include "llvm/ADT/StringMap.h"
using namespace llvm; using namespace llvm;
TargetIntrinsicInfo::TargetIntrinsicInfo(const char **desc, unsigned count) TargetIntrinsicInfo::TargetIntrinsicInfo() {
: Intrinsics(desc), NumIntrinsics(count) {
} }
TargetIntrinsicInfo::~TargetIntrinsicInfo() { TargetIntrinsicInfo::~TargetIntrinsicInfo() {
} }
unsigned TargetIntrinsicInfo::getIntrinsicID(Function *F) const {
const ValueName *ValName = F->getValueName();
if (!ValName)
return 0;
return lookupName(ValName->getKeyData(), ValName->getKeyLength());
}