Silence -Wunused-variable in release builds.
[llvm/stm8.git] / lib / Target / ARM / ARMMCExpr.cpp
blob2727ba8c8aa5f41a2309662a6e9425fcbf651a5b
1 //===-- ARMMCExpr.cpp - ARM specific MC expression classes ----------------===//
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 //===----------------------------------------------------------------------===//
10 #define DEBUG_TYPE "armmcexpr"
11 #include "ARMMCExpr.h"
12 #include "llvm/MC/MCContext.h"
13 #include "llvm/MC/MCAssembler.h"
14 using namespace llvm;
16 const ARMMCExpr*
17 ARMMCExpr::Create(VariantKind Kind, const MCExpr *Expr,
18 MCContext &Ctx) {
19 return new (Ctx) ARMMCExpr(Kind, Expr);
22 void ARMMCExpr::PrintImpl(raw_ostream &OS) const {
23 switch (Kind) {
24 default: assert(0 && "Invalid kind!");
25 case VK_ARM_HI16: OS << ":upper16:"; break;
26 case VK_ARM_LO16: OS << ":lower16:"; break;
29 const MCExpr *Expr = getSubExpr();
30 if (Expr->getKind() != MCExpr::SymbolRef)
31 OS << '(';
32 Expr->print(OS);
33 if (Expr->getKind() != MCExpr::SymbolRef)
34 OS << ')';
37 bool
38 ARMMCExpr::EvaluateAsRelocatableImpl(MCValue &Res,
39 const MCAsmLayout *Layout) const {
40 return false;
43 // FIXME: This basically copies MCObjectStreamer::AddValueSymbols. Perhaps
44 // that method should be made public?
45 static void AddValueSymbols_(const MCExpr *Value, MCAssembler *Asm) {
46 switch (Value->getKind()) {
47 case MCExpr::Target:
48 assert(0 && "Can't handle nested target expr!");
49 break;
51 case MCExpr::Constant:
52 break;
54 case MCExpr::Binary: {
55 const MCBinaryExpr *BE = cast<MCBinaryExpr>(Value);
56 AddValueSymbols_(BE->getLHS(), Asm);
57 AddValueSymbols_(BE->getRHS(), Asm);
58 break;
61 case MCExpr::SymbolRef:
62 Asm->getOrCreateSymbolData(cast<MCSymbolRefExpr>(Value)->getSymbol());
63 break;
65 case MCExpr::Unary:
66 AddValueSymbols_(cast<MCUnaryExpr>(Value)->getSubExpr(), Asm);
67 break;
71 void ARMMCExpr::AddValueSymbols(MCAssembler *Asm) const {
72 AddValueSymbols_(getSubExpr(), Asm);