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) {
69 Type(other.
Type), isEarlyClobber(other.isEarlyClobber),
70 MatchingInput(other.MatchingInput), isCommutative(other.isCommutative),
71 isIndirect(other.isIndirect), Codes(other.Codes),
72 isMultipleAlternative(other.isMultipleAlternative),
73 multipleAlternatives(other.multipleAlternatives),
74 currentAlternativeIndex(other.currentAlternativeIndex) {
83 unsigned multipleAlternativeCount = Str.
count(
'|') + 1;
84 unsigned multipleAlternativeIndex = 0;
88 isMultipleAlternative = (multipleAlternativeCount > 1 ?
true :
false);
89 if (isMultipleAlternative) {
90 multipleAlternatives.resize(multipleAlternativeCount);
91 pCodes = &multipleAlternatives[0].Codes;
94 isEarlyClobber =
false;
96 isCommutative =
false;
98 currentAlternativeIndex = 0;
104 }
else if (*I ==
'=') {
114 if (I == E)
return true;
117 bool DoneWithModifiers =
false;
118 while (!DoneWithModifiers) {
121 DoneWithModifiers =
true;
127 isEarlyClobber =
true;
133 isCommutative =
true;
140 if (!DoneWithModifiers) {
142 if (I == E)
return true;
151 if (ConstraintEnd == E)
return true;
152 pCodes->push_back(std::string(I, ConstraintEnd+1));
154 }
else if (
isdigit(static_cast<unsigned char>(*I))) {
157 while (I != E &&
isdigit(static_cast<unsigned char>(*I)))
159 pCodes->push_back(std::string(NumStart, I));
160 unsigned N =
atoi(pCodes->back().c_str());
162 if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[
N].Type !=
isOutput||
168 if (isMultipleAlternative) {
170 ConstraintsSoFar[
N].multipleAlternatives[multipleAlternativeIndex];
176 if (ConstraintsSoFar[N].hasMatchingInput())
179 ConstraintsSoFar[
N].MatchingInput = ConstraintsSoFar.size();
181 }
else if (*I ==
'|') {
182 multipleAlternativeIndex++;
183 pCodes = &multipleAlternatives[multipleAlternativeIndex].Codes;
185 }
else if (*I ==
'^') {
188 pCodes->push_back(std::string(I+1, I+3));
192 pCodes->push_back(std::string(I, I+1));
203 if (index < multipleAlternatives.size()) {
204 currentAlternativeIndex = index;
206 multipleAlternatives[currentAlternativeIndex];
208 Codes = scInfo.
Codes;
218 E = Constraints.
end();
I != E; ) {
224 if (ConstraintEnd ==
I ||
230 Result.push_back(Info);
237 if (
I == E) { Result.clear();
break; }
252 if (Constraints.empty() && !ConstStr.
empty())
return false;
254 unsigned NumOutputs = 0, NumInputs = 0, NumClobbers = 0;
255 unsigned NumIndirect = 0;
257 for (
unsigned i = 0, e = Constraints.size(); i != e; ++i) {
258 switch (Constraints[i].
Type) {
260 if ((NumInputs-NumIndirect) != 0 || NumClobbers != 0)
262 if (!Constraints[i].isIndirect) {
269 if (NumClobbers)
return false;
278 switch (NumOutputs) {
unsigned getNumParams() const
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar)
static bool isInput(const llvm::StringSet<> &Prefixes, StringRef Arg)
ConstraintInfoVector ParseConstraints() const
int atoi(const char *str);
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
static bool Verify(FunctionType *Ty, StringRef Constraints)
Type * getElementType() const
ConstraintInfo()
Default constructor.
size_t count(char C) const
Return the number of occurrences of C in the string.
PointerType * getType() const
LLVMContextImpl *const pImpl
signed char MatchingInput
FunctionType * getFunctionType() const
std::vector< std::string > ConstraintCodeVector
ConstraintCodeVector Codes
static PointerType * getUnqual(Type *ElementType)
ConstantUniqueMap< InlineAsmKeyType, const InlineAsmKeyType &, PointerType, InlineAsm > InlineAsms
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT)
Type * getReturnType() const
LLVM Value Representation.
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)
bool empty() const
empty - Check if the string is empty.