aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/InlineAsm.cpp
blob: 1eed8941beadd492739fbad27caf2138dcc601d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//===-- InlineAsm.cpp - Implement the InlineAsm class ---------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file was developed by Chris Lattner and is distributed under the
// University of Illinois Open Source License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the InlineAsm class.
//
//===----------------------------------------------------------------------===//

#include "llvm/InlineAsm.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Support/LeakDetector.h"
using namespace llvm;

InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString,
                     const std::string &constraints, bool hasSideEffects,
                     const std::string &name, Module *ParentModule)
  : Value(PointerType::get(Ty), Value::InlineAsmVal, name), 
    Parent(0), AsmString(asmString), Constraints(constraints), 
    AsmHasSideEffects(hasSideEffects) {
  LeakDetector::addGarbageObject(this);

  if (ParentModule)
    ParentModule->getInlineAsmList().push_back(this);
}

const FunctionType *InlineAsm::getFunctionType() const {
  return cast<FunctionType>(getType()->getElementType());
}

void InlineAsm::setParent(Module *parent) {
  if (getParent())
    LeakDetector::addGarbageObject(this);
  Parent = parent;
  if (getParent())
    LeakDetector::removeGarbageObject(this);
}

void InlineAsm::removeFromParent() {
  getParent()->getInlineAsmList().remove(this);
}

void InlineAsm::eraseFromParent() {
  getParent()->getInlineAsmList().erase(this);
}