blob: 1eed8941beadd492739fbad27caf2138dcc601d2 [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"
16#include "llvm/Module.h"
17#include "llvm/Support/LeakDetector.h"
18using namespace llvm;
19
20InlineAsm::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);
27
28 if (ParentModule)
29 ParentModule->getInlineAsmList().push_back(this);
30}
31
32const FunctionType *InlineAsm::getFunctionType() const {
33 return cast<FunctionType>(getType()->getElementType());
34}
35
36void InlineAsm::setParent(Module *parent) {
37 if (getParent())
38 LeakDetector::addGarbageObject(this);
39 Parent = parent;
40 if (getParent())
41 LeakDetector::removeGarbageObject(this);
42}
43
44void InlineAsm::removeFromParent() {
45 getParent()->getInlineAsmList().remove(this);
46}
47
48void InlineAsm::eraseFromParent() {
49 getParent()->getInlineAsmList().erase(this);
50}