blob: cc817e3795a2fcef0a321a4d1c3c5e64d75e0bc6 [file] [log] [blame]
Chris Lattnereef2fe72006-01-24 04:13:11 +00001//===-- 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 Lattnereef2fe72006-01-24 04:13:11 +000016using namespace llvm;
17
Chris Lattnera2d810d2006-01-25 22:26:05 +000018// NOTE: when memoizing the function type, we have to be careful to handle the
19// case when the type gets refined.
20
21InlineAsm *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 Lattnereef2fe72006-01-24 04:13:11 +000027InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString,
Chris Lattner8bbcda22006-01-25 18:57:27 +000028 const std::string &constraints, bool hasSideEffects)
29 : Value(PointerType::get(Ty), Value::InlineAsmVal), AsmString(asmString),
30 Constraints(constraints), HasSideEffects(hasSideEffects) {
Chris Lattnereef2fe72006-01-24 04:13:11 +000031
Chris Lattnera2d810d2006-01-25 22:26:05 +000032 // Do various checks on the constraint string and type.
33 assert(Verify(Ty, constraints) && "Function type not legal for constraints!");
Chris Lattnereef2fe72006-01-24 04:13:11 +000034}
35
36const FunctionType *InlineAsm::getFunctionType() const {
37 return cast<FunctionType>(getType()->getElementType());
38}
Chris Lattnera2d810d2006-01-25 22:26:05 +000039
40bool InlineAsm::Verify(const FunctionType *Ty, const std::string &Constraints) {
41 return true;
42}