1 //===-- llvm/InlineAsm.h - Class to represent inline asm strings-*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class represents the inline asm strings, which are Value*'s that are
11 // used as the callee operand of call instructions. InlineAsm's are uniqued
12 // like constants, and created via InlineAsm::get(...).
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_INLINEASM_H
17 #define LLVM_INLINEASM_H
19 #include "llvm/Value.h"
24 struct AssemblyAnnotationWriter;
29 class InlineAsm : public Value {
30 InlineAsm(const InlineAsm &); // do not implement
31 void operator=(const InlineAsm&); // do not implement
33 std::string AsmString, Constraints;
36 InlineAsm(const FunctionType *Ty, const std::string &AsmString,
37 const std::string &Constraints, bool hasSideEffects);
40 /// InlineAsm::get - Return the the specified uniqued inline asm string.
42 static InlineAsm *get(const FunctionType *Ty, const std::string &AsmString,
43 const std::string &Constraints, bool hasSideEffects);
45 bool hasSideEffects() const { return HasSideEffects; }
47 /// getType - InlineAsm's are always pointers.
49 const PointerType *getType() const {
50 return reinterpret_cast<const PointerType*>(Value::getType());
53 /// getFunctionType - InlineAsm's are always pointers to functions.
55 const FunctionType *getFunctionType() const;
57 const std::string &getAsmString() const { return AsmString; }
58 const std::string &getConstraintString() const { return Constraints; }
60 virtual void print(std::ostream &O) const { print(O, 0); }
61 void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
63 /// Verify - This static method can be used by the parser to check to see if
64 /// the specified constraint string is legal for the type. This returns true
65 /// if legal, false if not.
67 static bool Verify(const FunctionType *Ty, const std::string &Constraints);
69 // Constraint String Parsing
70 enum ConstraintPrefix {
73 isIndirectOutput, // '==x'
77 /// ParseConstraints - Split up the constraint string into the specific
78 /// constraints and their prefixes. If this returns an empty vector, and if
79 /// the constraint string itself isn't empty, there was an error parsing.
80 static std::vector<std::pair<ConstraintPrefix, std::string> >
81 ParseConstraints(const std::string &ConstraintString);
83 std::vector<std::pair<ConstraintPrefix, std::string> >
84 ParseConstraints() const {
85 return ParseConstraints(Constraints);
88 // Methods for support type inquiry through isa, cast, and dyn_cast:
89 static inline bool classof(const InlineAsm *) { return true; }
90 static inline bool classof(const Value *V) {
91 return V->getValueType() == Value::InlineAsmVal;
95 } // End llvm namespace