10b57cec5SDimitry Andric //=--- X86MCExpr.h - X86 specific MC expression classes ---*- C++ -*-=// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file describes X86-specific MCExprs, i.e, registers used for 100b57cec5SDimitry Andric // extended variable assignments. 110b57cec5SDimitry Andric // 120b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCEXPR_H 150b57cec5SDimitry Andric #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCEXPR_H 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric #include "X86ATTInstPrinter.h" 180b57cec5SDimitry Andric #include "llvm/MC/MCAsmInfo.h" 190b57cec5SDimitry Andric #include "llvm/MC/MCContext.h" 200b57cec5SDimitry Andric #include "llvm/MC/MCExpr.h" 2181ad6265SDimitry Andric #include "llvm/Support/Casting.h" 220b57cec5SDimitry Andric #include "llvm/Support/ErrorHandling.h" 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric namespace llvm { 250b57cec5SDimitry Andric 260b57cec5SDimitry Andric class X86MCExpr : public MCTargetExpr { 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric private: 290b57cec5SDimitry Andric const int64_t RegNo; // All 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric explicit X86MCExpr(int64_t R) : RegNo(R) {} 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric public: 340b57cec5SDimitry Andric /// @name Construction 350b57cec5SDimitry Andric /// @{ 360b57cec5SDimitry Andric 370b57cec5SDimitry Andric static const X86MCExpr *create(int64_t RegNo, MCContext &Ctx) { 380b57cec5SDimitry Andric return new (Ctx) X86MCExpr(RegNo); 390b57cec5SDimitry Andric } 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric /// @} 420b57cec5SDimitry Andric /// @name Accessors 430b57cec5SDimitry Andric /// @{ 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric /// getSubExpr - Get the child of this expression. 460b57cec5SDimitry Andric int64_t getRegNo() const { return RegNo; } 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric /// @} 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override { 510b57cec5SDimitry Andric if (!MAI || MAI->getAssemblerDialect() == 0) 520b57cec5SDimitry Andric OS << '%'; 530b57cec5SDimitry Andric OS << X86ATTInstPrinter::getRegisterName(RegNo); 540b57cec5SDimitry Andric } 550b57cec5SDimitry Andric 56*0fca6ea1SDimitry Andric bool evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, 570b57cec5SDimitry Andric const MCFixup *Fixup) const override { 580b57cec5SDimitry Andric return false; 590b57cec5SDimitry Andric } 600b57cec5SDimitry Andric // Register values should be inlined as they are not valid .set expressions. 610b57cec5SDimitry Andric bool inlineAssignedExpr() const override { return true; } 620b57cec5SDimitry Andric bool isEqualTo(const MCExpr *X) const override { 630b57cec5SDimitry Andric if (auto *E = dyn_cast<X86MCExpr>(X)) 640b57cec5SDimitry Andric return getRegNo() == E->getRegNo(); 650b57cec5SDimitry Andric return false; 660b57cec5SDimitry Andric } 6706c3fb27SDimitry Andric void visitUsedExpr(MCStreamer &Streamer) const override {} 680b57cec5SDimitry Andric MCFragment *findAssociatedFragment() const override { return nullptr; } 690b57cec5SDimitry Andric 700b57cec5SDimitry Andric // There are no TLS X86MCExprs at the moment. 710b57cec5SDimitry Andric void fixELFSymbolsInTLSFixups(MCAssembler &Asm) const override {} 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric static bool classof(const MCExpr *E) { 740b57cec5SDimitry Andric return E->getKind() == MCExpr::Target; 750b57cec5SDimitry Andric } 760b57cec5SDimitry Andric }; 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric } // end namespace llvm 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric #endif 81