Path: blob/main/contrib/llvm-project/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCExpr.cpp
35295 views
//===-- XtensaMCExpr.cpp - Xtensa specific MC expression classes ----------===//1//2// The LLVM Compiler Infrastructure3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9//10// This file contains the implementation of the assembly expression modifiers11// accepted by the Xtensa architecture12//13//===----------------------------------------------------------------------===//1415#include "XtensaMCExpr.h"16#include "llvm/MC/MCAssembler.h"17#include "llvm/MC/MCContext.h"18#include "llvm/MC/MCStreamer.h"19#include "llvm/MC/MCSymbolELF.h"20#include "llvm/MC/MCValue.h"21#include "llvm/Object/ELF.h"22#include "llvm/Support/ErrorHandling.h"2324using namespace llvm;2526#define DEBUG_TYPE "xtensamcexpr"2728const XtensaMCExpr *XtensaMCExpr::create(const MCExpr *Expr, VariantKind Kind,29MCContext &Ctx) {30return new (Ctx) XtensaMCExpr(Expr, Kind);31}3233void XtensaMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {34bool HasVariant = getKind() != VK_Xtensa_None;35if (HasVariant)36OS << '%' << getVariantKindName(getKind()) << '(';37Expr->print(OS, MAI);38if (HasVariant)39OS << ')';40}4142bool XtensaMCExpr::evaluateAsRelocatableImpl(MCValue &Res,43const MCAssembler *Asm,44const MCFixup *Fixup) const {45return getSubExpr()->evaluateAsRelocatable(Res, Asm, Fixup);46}4748void XtensaMCExpr::visitUsedExpr(MCStreamer &Streamer) const {49Streamer.visitUsedExpr(*getSubExpr());50}5152XtensaMCExpr::VariantKind XtensaMCExpr::getVariantKindForName(StringRef name) {53return StringSwitch<XtensaMCExpr::VariantKind>(name).Default(54VK_Xtensa_Invalid);55}5657StringRef XtensaMCExpr::getVariantKindName(VariantKind Kind) {58switch (Kind) {59default:60llvm_unreachable("Invalid ELF symbol kind");61}62}636465