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 {
33 const VariantKind Kind;
35 const int AssemblerDialect;
37 explicit PPCMCExpr(VariantKind _Kind, const MCExpr *_Expr,
38 int _AssemblerDialect)
39 : Kind(_Kind), Expr(_Expr), AssemblerDialect(_AssemblerDialect) {}
42 /// @name Construction
45 static const PPCMCExpr *Create(VariantKind Kind, const MCExpr *Expr,
48 static const PPCMCExpr *CreateLo(const MCExpr *Expr, MCContext &Ctx) {
49 return Create(VK_PPC_LO, Expr, Ctx);
52 static const PPCMCExpr *CreateHi(const MCExpr *Expr, MCContext &Ctx) {
53 return Create(VK_PPC_HI, Expr, Ctx);
56 static const PPCMCExpr *CreateHa(const MCExpr *Expr, MCContext &Ctx) {
57 return Create(VK_PPC_HA, Expr, Ctx);
64 /// getOpcode - Get the kind of this expression.
65 VariantKind getKind() const { return Kind; }
67 /// getSubExpr - Get the child of this expression.
68 const MCExpr *getSubExpr() const { return Expr; }
70 /// isDarwinSyntax - True if expression is to be printed using Darwin syntax.
71 bool isDarwinSyntax() const { return AssemblerDialect == 1; }
76 void PrintImpl(raw_ostream &OS) const;
77 bool EvaluateAsRelocatableImpl(MCValue &Res,
78 const MCAsmLayout *Layout) const;
79 void AddValueSymbols(MCAssembler *) const;
80 const MCSection *FindAssociatedSection() const {
81 return getSubExpr()->FindAssociatedSection();
84 // There are no TLS PPCMCExprs at the moment.
85 void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {}
87 static bool classof(const MCExpr *E) {
88 return E->getKind() == MCExpr::Target;
91 } // end namespace llvm