Mercurial > hg > Members > tobaru > cbc > CbC_llvm
comparison lib/MC/MCValue.cpp @ 77:54457678186b
LLVM 3.6
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Sep 2014 22:06:00 +0900 |
parents | 95c75e76d11b |
children | 60c9769439b8 |
comparison
equal
deleted
inserted
replaced
34:e874dbf0ad9d | 77:54457678186b |
---|---|
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 | 9 |
10 #include "llvm/MC/MCValue.h" | 10 #include "llvm/MC/MCValue.h" |
11 #include "llvm/MC/MCExpr.h" | 11 #include "llvm/MC/MCExpr.h" |
12 #include "llvm/Support/Debug.h" | 12 #include "llvm/Support/Debug.h" |
13 #include "llvm/Support/ErrorHandling.h" | |
13 #include "llvm/Support/raw_ostream.h" | 14 #include "llvm/Support/raw_ostream.h" |
14 | 15 |
15 using namespace llvm; | 16 using namespace llvm; |
16 | 17 |
17 void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const { | 18 void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const { |
18 if (isAbsolute()) { | 19 if (isAbsolute()) { |
19 OS << getConstant(); | 20 OS << getConstant(); |
20 return; | 21 return; |
21 } | 22 } |
23 | |
24 // FIXME: prints as a number, which isn't ideal. But the meaning will be | |
25 // target-specific anyway. | |
26 if (getRefKind()) | |
27 OS << ':' << getRefKind() << ':'; | |
22 | 28 |
23 getSymA()->print(OS); | 29 getSymA()->print(OS); |
24 | 30 |
25 if (getSymB()) { | 31 if (getSymB()) { |
26 OS << " - "; | 32 OS << " - "; |
31 OS << " + " << getConstant(); | 37 OS << " + " << getConstant(); |
32 } | 38 } |
33 | 39 |
34 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | 40 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
35 void MCValue::dump() const { | 41 void MCValue::dump() const { |
36 print(dbgs(), 0); | 42 print(dbgs(), nullptr); |
37 } | 43 } |
38 #endif | 44 #endif |
45 | |
46 MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const { | |
47 const MCSymbolRefExpr *B = getSymB(); | |
48 if (B) { | |
49 if (B->getKind() != MCSymbolRefExpr::VK_None) | |
50 llvm_unreachable("unsupported"); | |
51 } | |
52 | |
53 const MCSymbolRefExpr *A = getSymA(); | |
54 if (!A) | |
55 return MCSymbolRefExpr::VK_None; | |
56 | |
57 MCSymbolRefExpr::VariantKind Kind = A->getKind(); | |
58 if (Kind == MCSymbolRefExpr::VK_WEAKREF) | |
59 return MCSymbolRefExpr::VK_None; | |
60 return Kind; | |
61 } |