add some useful accessors :)
[oota-llvm.git] / include / llvm / InlineAsm.h
1 //===-- llvm/InlineAsm.h - Class to represent inline asm strings-*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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(...).
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_INLINEASM_H
17 #define LLVM_INLINEASM_H
18
19 #include "llvm/Value.h"
20
21 namespace llvm {
22
23 struct AssemblyAnnotationWriter;
24 class PointerType;
25 class FunctionType;
26 class Module;
27
28 class InlineAsm : public Value {
29   InlineAsm(const InlineAsm &);             // do not implement
30   void operator=(const InlineAsm&);         // do not implement
31
32   std::string AsmString, Constraints;
33   bool HasSideEffects;
34   
35   InlineAsm(const FunctionType *Ty, const std::string &AsmString,
36             const std::string &Constraints, bool hasSideEffects);
37 public:
38
39   /// InlineAsm::get - Return the the specified uniqued inline asm string.
40   ///
41   static InlineAsm *get(const FunctionType *Ty, const std::string &AsmString,
42                         const std::string &Constraints, bool hasSideEffects);
43   
44   bool hasSideEffects() const { return HasSideEffects; }
45   
46   /// getType - InlineAsm's are always pointers.
47   ///
48   const PointerType *getType() const {
49     return reinterpret_cast<const PointerType*>(Value::getType());
50   }
51   
52   /// getFunctionType - InlineAsm's are always pointers to functions.
53   ///
54   const FunctionType *getFunctionType() const;
55   
56   const std::string &getAsmString() const { return AsmString; }
57   const std::string &getConstraintString() const { return Constraints; }
58
59   virtual void print(std::ostream &O) const { print(O, 0); }
60   void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
61
62   // Methods for support type inquiry through isa, cast, and dyn_cast:
63   static inline bool classof(const InlineAsm *) { return true; }
64   static inline bool classof(const Value *V) {
65     return V->getValueType() == Value::InlineAsmVal;
66   }
67 };
68
69 } // End llvm namespace
70
71 #endif