24 InlineAsm::~InlineAsm() {
29 StringRef Constraints,
bool hasSideEffects,
37 InlineAsm::InlineAsm(
PointerType *Ty,
const std::string &asmString,
38 const std::string &constraints,
bool hasSideEffects,
39 bool isAlignStack, AsmDialect asmDialect)
41 AsmString(asmString), Constraints(constraints),
42 HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
47 "Function type not legal for constraints!");
50 void InlineAsm::destroyConstant() {
62 MatchingInput(-1), isCommutative(
false),
63 isIndirect(
false), isMultipleAlternative(
false),
64 currentAlternativeIndex(0) {
73 unsigned multipleAlternativeCount = Str.
count(
'|') + 1;
74 unsigned multipleAlternativeIndex = 0;
78 isMultipleAlternative = multipleAlternativeCount > 1;
79 if (isMultipleAlternative) {
80 multipleAlternatives.resize(multipleAlternativeCount);
81 pCodes = &multipleAlternatives[0].Codes;
84 isEarlyClobber =
false;
86 isCommutative =
false;
88 currentAlternativeIndex = 0;
96 if (I != E && *I !=
'{')
98 }
else if (*I ==
'=') {
108 if (I == E)
return true;
111 bool DoneWithModifiers =
false;
112 while (!DoneWithModifiers) {
115 DoneWithModifiers =
true;
121 isEarlyClobber =
true;
127 isCommutative =
true;
134 if (!DoneWithModifiers) {
136 if (I == E)
return true;
145 if (ConstraintEnd == E)
return true;
146 pCodes->push_back(std::string(I, ConstraintEnd+1));
148 }
else if (isdigit(static_cast<unsigned char>(*I))) {
151 while (I != E && isdigit(static_cast<unsigned char>(*I)))
153 pCodes->push_back(std::string(NumStart, I));
154 unsigned N = atoi(pCodes->back().c_str());
156 if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[
N].Type !=
isOutput||
162 if (isMultipleAlternative) {
164 ConstraintsSoFar[
N].multipleAlternatives[multipleAlternativeIndex];
170 if (ConstraintsSoFar[N].hasMatchingInput() &&
171 (
size_t)ConstraintsSoFar[N].MatchingInput !=
172 ConstraintsSoFar.size())
175 ConstraintsSoFar[
N].MatchingInput = ConstraintsSoFar.size();
177 }
else if (*I ==
'|') {
178 multipleAlternativeIndex++;
179 pCodes = &multipleAlternatives[multipleAlternativeIndex].Codes;
181 }
else if (*I ==
'^') {
184 pCodes->push_back(std::string(I+1, I+3));
188 pCodes->push_back(std::string(I, I+1));
199 if (index < multipleAlternatives.size()) {
200 currentAlternativeIndex = index;
202 multipleAlternatives[currentAlternativeIndex];
204 Codes = scInfo.
Codes;
214 E = Constraints.
end();
I != E; ) {
220 if (ConstraintEnd ==
I ||
226 Result.push_back(Info);
251 if (Constraints.empty() && !ConstStr.
empty())
return false;
253 unsigned NumOutputs = 0, NumInputs = 0, NumClobbers = 0;
254 unsigned NumIndirect = 0;
256 for (
unsigned i = 0, e = Constraints.size(); i != e; ++i) {
257 switch (Constraints[i].
Type) {
259 if ((NumInputs-NumIndirect) != 0 || NumClobbers != 0)
261 if (!Constraints[i].isIndirect) {
268 if (NumClobbers)
return false;
277 switch (NumOutputs) {
unsigned getNumParams() const
getNumParams - Return the number of fixed parameters this function type requires. ...
bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar)
Parse - Analyze the specified string (e.g.
static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg)
StructType - Class to represent struct types.
ConstraintInfoVector ParseConstraints() const
ParseConstraints - Parse the constraints of this inlineasm object, returning them the same way that P...
ConstantUniqueMap< InlineAsm > InlineAsms
FunctionType - Class to represent function types.
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
static bool Verify(FunctionType *Ty, StringRef Constraints)
Verify - This static method can be used by the parser to check to see if the specified constraint str...
Type * getElementType() const
PointerType - Class to represent pointers.
The instances of the Type class are immutable: once they are created, they are never changed...
ConstraintInfo()
Default constructor.
size_t count(char C) const
Return the number of occurrences of C in the string.
PointerType * getType() const
getType - InlineAsm's are always pointers.
LLVMContextImpl *const pImpl
signed char MatchingInput
MatchingInput - If this is not -1, this is an output constraint where an input constraint is required...
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
std::vector< std::string > ConstraintCodeVector
ConstraintCodeVector Codes
Code - The constraint code, either the register name (in braces) or the constraint letter/number...
static PointerType * getUnqual(Type *ElementType)
PointerType::getUnqual - This constructs a pointer to an object of the specified type in the generic ...
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool isStructTy() const
isStructTy - True if this is an instance of StructType.
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT)
InlineAsm::get - Return the specified uniqued inline asm string.
Type * getReturnType() const
LLVM Value Representation.
StringRef - Represent a constant reference to a string, i.e.
unsigned getNumElements() const
Random access to the elements.
std::vector< ConstraintInfo > ConstraintInfoVector
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
void selectAlternative(unsigned index)
selectAlternative - Point this constraint to the alternative constraint indicated by the index...
bool empty() const
empty - Check if the string is empty.