Chris Lattner | eef2fe7 | 2006-01-24 04:13:11 +0000 | [diff] [blame] | 1 | //===-- InlineAsm.cpp - Implement the InlineAsm class ---------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the InlineAsm class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/InlineAsm.h" |
| 15 | #include "llvm/DerivedTypes.h" |
Chris Lattner | eef2fe7 | 2006-01-24 04:13:11 +0000 | [diff] [blame] | 16 | using namespace llvm; |
| 17 | |
Chris Lattner | a2d810d | 2006-01-25 22:26:05 +0000 | [diff] [blame] | 18 | // NOTE: when memoizing the function type, we have to be careful to handle the |
| 19 | // case when the type gets refined. |
| 20 | |
| 21 | InlineAsm *InlineAsm::get(const FunctionType *Ty, const std::string &AsmString, |
| 22 | const std::string &Constraints, bool hasSideEffects) { |
| 23 | // FIXME: memoize! |
| 24 | return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects); |
| 25 | } |
| 26 | |
Chris Lattner | eef2fe7 | 2006-01-24 04:13:11 +0000 | [diff] [blame] | 27 | InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString, |
Chris Lattner | 8bbcda2 | 2006-01-25 18:57:27 +0000 | [diff] [blame] | 28 | const std::string &constraints, bool hasSideEffects) |
| 29 | : Value(PointerType::get(Ty), Value::InlineAsmVal), AsmString(asmString), |
| 30 | Constraints(constraints), HasSideEffects(hasSideEffects) { |
Chris Lattner | eef2fe7 | 2006-01-24 04:13:11 +0000 | [diff] [blame] | 31 | |
Chris Lattner | a2d810d | 2006-01-25 22:26:05 +0000 | [diff] [blame] | 32 | // Do various checks on the constraint string and type. |
| 33 | assert(Verify(Ty, constraints) && "Function type not legal for constraints!"); |
Chris Lattner | eef2fe7 | 2006-01-24 04:13:11 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | const FunctionType *InlineAsm::getFunctionType() const { |
| 37 | return cast<FunctionType>(getType()->getElementType()); |
| 38 | } |
Chris Lattner | a2d810d | 2006-01-25 22:26:05 +0000 | [diff] [blame] | 39 | |
| 40 | bool InlineAsm::Verify(const FunctionType *Ty, const std::string &Constraints) { |
| 41 | return true; |
| 42 | } |