1 //===-- InlineAsm.cpp - Implement the InlineAsm class ---------------------===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file implements the InlineAsm class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/InlineAsm.h"
15 #include "llvm/DerivedTypes.h"
16 #include "llvm/Module.h"
17 #include "llvm/Support/LeakDetector.h"
20 InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString,
21 const std::string &constraints, bool hasSideEffects,
22 const std::string &name, Module *ParentModule)
23 : Value(PointerType::get(Ty), Value::InlineAsmVal, name),
24 Parent(0), AsmString(asmString), Constraints(constraints),
25 AsmHasSideEffects(hasSideEffects) {
26 LeakDetector::addGarbageObject(this);
29 ParentModule->getInlineAsmList().push_back(this);
32 const FunctionType *InlineAsm::getFunctionType() const {
33 return cast<FunctionType>(getType()->getElementType());
36 void InlineAsm::setParent(Module *parent) {
38 LeakDetector::addGarbageObject(this);
41 LeakDetector::removeGarbageObject(this);
44 void InlineAsm::removeFromParent() {
45 getParent()->getInlineAsmList().remove(this);
48 void InlineAsm::eraseFromParent() {
49 getParent()->getInlineAsmList().erase(this);