Remove unneeded includes.
[oota-llvm.git] / lib / MC / MCContext.cpp
1 //===- lib/MC/MCContext.cpp - Machine Code Context ------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/MC/MCContext.h"
11 #include "llvm/MC/MCSection.h"
12 #include "llvm/MC/MCSymbol.h"
13 #include "llvm/ADT/SmallString.h"
14 #include "llvm/ADT/Twine.h"
15 using namespace llvm;
16
17 MCContext::MCContext() {
18 }
19
20 MCContext::~MCContext() {
21   // NOTE: The sections are all allocated out of a bump pointer allocator,
22   // we don't need to free them here.
23 }
24
25 MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) {
26   assert(!Name.empty() && "Normal symbols cannot be unnamed!");
27   MCSymbol *&Entry = Symbols[Name];
28   if (Entry) return Entry;
29
30   return Entry = new (*this) MCSymbol(Name, false);
31 }
32
33 MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) {
34   SmallString<128> NameSV;
35   Name.toVector(NameSV);
36   return GetOrCreateSymbol(NameSV.str());
37 }
38
39
40 MCSymbol *MCContext::GetOrCreateTemporarySymbol(StringRef Name) {
41   // If unnamed, just create a symbol.
42   if (Name.empty())
43     new (*this) MCSymbol("", true);
44     
45   // Otherwise create as usual.
46   MCSymbol *&Entry = Symbols[Name];
47   if (Entry) return Entry;
48   return Entry = new (*this) MCSymbol(Name, true);
49 }
50
51 MCSymbol *MCContext::GetOrCreateTemporarySymbol(const Twine &Name) {
52   SmallString<128> NameSV;
53   Name.toVector(NameSV);
54   return GetOrCreateTemporarySymbol(NameSV.str());
55 }
56
57
58 MCSymbol *MCContext::LookupSymbol(StringRef Name) const {
59   return Symbols.lookup(Name);
60 }