1 //===-- PPCMCExpr.h - PPC specific MC expression classes --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
13 #include "llvm/MC/MCExpr.h"
14 #include "llvm/MC/MCValue.h"
15 #include "llvm/MC/MCAsmLayout.h"
19 class PPCMCExpr : public MCTargetExpr {
28 const VariantKind Kind;
30 const int AssemblerDialect;
32 explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr,
33 int _AssemblerDialect)
34 : Kind(_Kind), Expr(_Expr), AssemblerDialect(_AssemblerDialect) {}
37 /// @name Construction
40 static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
43 static const PPCMCExpr *CreateHa16(const MCExpr *Expr, MCContext &Ctx) {
44 return Create(VK_PPC_HA16, Expr, Ctx);
47 static const PPCMCExpr *CreateLo16(const MCExpr *Expr, MCContext &Ctx) {
48 return Create(VK_PPC_LO16, Expr, Ctx);
55 /// getOpcode - Get the kind of this expression.
56 VariantKind getKind() const { return Kind; }
58 /// getSubExpr - Get the child of this expression.
59 const MCExpr *getSubExpr() const { return Expr; }
61 /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
62 bool isDarwinSyntax() const { return AssemblerDialect == 1; }
67 void PrintImpl(raw_ostream &OS) const;
68 bool EvaluateAsRelocatableImpl(MCValue &Res,
69 const MCAsmLayout *Layout) const;
70 void AddValueSymbols(MCAssembler *) const;
71 const MCSection *FindAssociatedSection() const {
72 return getSubExpr()->FindAssociatedSection();
75 // There are no TLS PPCMCExprs at the moment.
76 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
78 static bool classof(const MCExpr *E) {
79 return E->getKind() == MCExpr::Target;
82 } // end namespace llvm