X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FConstantsContext.h;h=2f2fac53f062e93e6c589372a61fcec649d39ed3;hb=3472766f9eb7d66f234c390ce1b3a8b76f0ee9ce;hp=c798ba2664cfe5a42bffe87c46788af8523f5892;hpb=fdfeb6976f07ad10d809b922ed7376ba2a3539be;p=oota-llvm.git diff --git a/lib/VMCore/ConstantsContext.h b/lib/VMCore/ConstantsContext.h index c798ba2664c..2f2fac53f06 100644 --- a/lib/VMCore/ConstantsContext.h +++ b/lib/VMCore/ConstantsContext.h @@ -15,6 +15,7 @@ #ifndef LLVM_CONSTANTSCONTEXT_H #define LLVM_CONSTANTSCONTEXT_H +#include "llvm/InlineAsm.h" #include "llvm/Instructions.h" #include "llvm/Operator.h" #include "llvm/Support/Debug.h" @@ -327,6 +328,39 @@ struct ExprMapKeyType { } }; +struct InlineAsmKeyType { + InlineAsmKeyType(StringRef AsmString, + StringRef Constraints, bool hasSideEffects, + bool isAlignStack) + : asm_string(AsmString), constraints(Constraints), + has_side_effects(hasSideEffects), is_align_stack(isAlignStack) {} + std::string asm_string; + std::string constraints; + bool has_side_effects; + bool is_align_stack; + bool operator==(const InlineAsmKeyType& that) const { + return this->asm_string == that.asm_string && + this->constraints == that.constraints && + this->has_side_effects == that.has_side_effects && + this->is_align_stack == that.is_align_stack; + } + bool operator<(const InlineAsmKeyType& that) const { + if (this->asm_string != that.asm_string) + return this->asm_string < that.asm_string; + if (this->constraints != that.constraints) + return this->constraints < that.constraints; + if (this->has_side_effects != that.has_side_effects) + return this->has_side_effects < that.has_side_effects; + if (this->is_align_stack != that.is_align_stack) + return this->is_align_stack < that.is_align_stack; + return false; + } + + bool operator!=(const InlineAsmKeyType& that) const { + return !(*this == that); + } +}; + // The number of operands for each ConstantCreator::create method is // determined by the ConstantTraits template. // ConstantCreator - A class that is used to create constants by @@ -517,6 +551,23 @@ struct ConstantKeyData { } }; +template<> +struct ConstantCreator { + static InlineAsm *create(const PointerType *Ty, const InlineAsmKeyType &Key) { + return new InlineAsm(Ty, Key.asm_string, Key.constraints, + Key.has_side_effects, Key.is_align_stack); + } +}; + +template<> +struct ConstantKeyData { + typedef InlineAsmKeyType ValType; + static ValType getValType(InlineAsm *Asm) { + return InlineAsmKeyType(Asm->getAsmString(), Asm->getConstraintString(), + Asm->hasSideEffects(), Asm->isAlignStack()); + } +}; + template class ConstantUniqueMap : public AbstractTypeUser { @@ -549,8 +600,8 @@ public: void freeConstants() { for (typename MapTy::iterator I=Map.begin(), E=Map.end(); I != E; ++I) { - if (I->second->use_empty()) - delete I->second; + // Asserts that use_empty(). + delete I->second; } }