30 InlineAsm::InlineAsm(
FunctionType *FTy,
const std::string &asmString,
31 const std::string &constraints,
bool hasSideEffects,
32 bool isAlignStack, AsmDialect asmDialect)
34 AsmString(asmString), Constraints(constraints), FTy(FTy),
35 HasSideEffects(hasSideEffects), IsAlignStack(isAlignStack),
39 "Function type not legal for constraints!");
43 StringRef Constraints,
bool hasSideEffects,
46 isAlignStack, asmDialect);
51 void InlineAsm::destroyConstant() {
52 getType()->getContext().pImpl->InlineAsms.remove(
this);
66 unsigned multipleAlternativeCount = Str.
count(
'|') + 1;
67 unsigned multipleAlternativeIndex = 0;
71 isMultipleAlternative = multipleAlternativeCount > 1;
72 if (isMultipleAlternative) {
73 multipleAlternatives.resize(multipleAlternativeCount);
74 pCodes = &multipleAlternatives[0].Codes;
77 isEarlyClobber =
false;
81 currentAlternativeIndex = 0;
89 if (I !=
E && *I !=
'{')
91 }
else if (*I ==
'=') {
101 if (I ==
E)
return true;
104 bool DoneWithModifiers =
false;
105 while (!DoneWithModifiers) {
108 DoneWithModifiers =
true;
111 if (
Type != isOutput ||
114 isEarlyClobber =
true;
117 if (
Type == isClobber ||
127 if (!DoneWithModifiers) {
129 if (I ==
E)
return true;
138 if (ConstraintEnd ==
E)
return true;
139 pCodes->push_back(
StringRef(I, ConstraintEnd+1 - I));
141 }
else if (isdigit(static_cast<unsigned char>(*I))) {
144 while (I !=
E && isdigit(static_cast<unsigned char>(*I)))
146 pCodes->push_back(
StringRef(NumStart, I - NumStart));
147 unsigned N = atoi(pCodes->back().c_str());
149 if (N >= ConstraintsSoFar.size() || ConstraintsSoFar[
N].Type != isOutput||
155 if (isMultipleAlternative) {
156 if (multipleAlternativeIndex >=
157 ConstraintsSoFar[N].multipleAlternatives.size())
160 ConstraintsSoFar[
N].multipleAlternatives[multipleAlternativeIndex];
167 if (ConstraintsSoFar[N].hasMatchingInput() &&
168 (
size_t)ConstraintsSoFar[N].MatchingInput !=
169 ConstraintsSoFar.size())
172 ConstraintsSoFar[
N].MatchingInput = ConstraintsSoFar.size();
173 assert(ConstraintsSoFar[N].MatchingInput >= 0);
175 }
else if (*I ==
'|') {
176 multipleAlternativeIndex++;
177 pCodes = &multipleAlternatives[multipleAlternativeIndex].Codes;
179 }
else if (*I ==
'^') {
184 }
else if (*I ==
'@') {
187 unsigned char C =
static_cast<unsigned char>(*I);
188 assert(isdigit(C) &&
"Expected a digit!");
190 assert(N > 0 &&
"Found a zero letter constraint!");
207 if (index < multipleAlternatives.size()) {
208 currentAlternativeIndex = index;
210 multipleAlternatives[currentAlternativeIndex];
212 Codes = scInfo.
Codes;
222 E = Constraints.
end();
I !=
E; ) {
228 if (ConstraintEnd ==
I ||
234 Result.push_back(Info);
259 if (Constraints.empty() && !ConstStr.
empty())
return false;
261 unsigned NumOutputs = 0, NumInputs = 0, NumClobbers = 0;
262 unsigned NumIndirect = 0;
264 for (
unsigned i = 0,
e = Constraints.size(); i !=
e; ++i) {
265 switch (Constraints[i].
Type) {
267 if ((NumInputs-NumIndirect) != 0 || NumClobbers != 0)
269 if (!Constraints[i].isIndirect) {
276 if (NumClobbers)
return false;
285 switch (NumOutputs) {
This class represents lattice values for constants.
unsigned getNumElements() const
Random access to the elements.
bool Parse(StringRef Str, ConstraintInfoVector &ConstraintsSoFar)
Parse - Analyze the specified string (e.g.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
std::vector< std::string > ConstraintCodeVector
LLVM_NODISCARD size_t count(char C) const
Return the number of occurrences of C in the string.
Class to represent struct types.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
ConstantUniqueMap< InlineAsm > InlineAsms
Class to represent function types.
ppc ctr loops PowerPC CTR Loops Verify
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...
Analysis containing CSE Info
Class to represent pointers.
bool isVoidTy() const
Return true if this is 'void'.
The instances of the Type class are immutable: once they are created, they are never changed...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
static wasm::ValType getType(const TargetRegisterClass *RC)
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
LLVMContextImpl *const pImpl
std::vector< ConstraintInfo > ConstraintInfoVector
ConstraintCodeVector Codes
Code - The constraint code, either the register name (in braces) or the constraint letter/number...
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
Type * getReturnType() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
FunctionType * getFunctionType() const
getFunctionType - InlineAsm's are always pointers to functions.
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isInput(const StringSet<> &Prefixes, StringRef Arg)
LLVM Value Representation.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static bool isCommutative(Instruction *I)
int MatchingInput
MatchingInput - If this is not -1, this is an output constraint where an input constraint is required...
StringRef - Represent a constant reference to a string, i.e.
ConstraintInfoVector ParseConstraints() const
ParseConstraints - Parse the constraints of this inlineasm object, returning them the same way that P...
bool isStructTy() const
True if this is an instance of StructType.
void selectAlternative(unsigned index)
selectAlternative - Point this constraint to the alternative constraint indicated by the index...