[AMDGPU] Check for immediate SrcC in mfma in AsmParser
[llvm-core.git] / lib / Target / Lanai / MCTargetDesc / LanaiMCExpr.cpp
blob56d5fbf40360fb7b2d6562765862c1aacfca1ba9
1 //===-- LanaiMCExpr.cpp - Lanai specific MC expression classes ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "LanaiMCExpr.h"
10 #include "llvm/MC/MCAssembler.h"
11 #include "llvm/MC/MCContext.h"
12 #include "llvm/MC/MCStreamer.h"
13 using namespace llvm;
15 #define DEBUG_TYPE "lanaimcexpr"
17 const LanaiMCExpr *LanaiMCExpr::create(VariantKind Kind, const MCExpr *Expr,
18 MCContext &Ctx) {
19 return new (Ctx) LanaiMCExpr(Kind, Expr);
22 void LanaiMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
23 if (Kind == VK_Lanai_None) {
24 Expr->print(OS, MAI);
25 return;
28 switch (Kind) {
29 default:
30 llvm_unreachable("Invalid kind!");
31 case VK_Lanai_ABS_HI:
32 OS << "hi";
33 break;
34 case VK_Lanai_ABS_LO:
35 OS << "lo";
36 break;
39 OS << '(';
40 const MCExpr *Expr = getSubExpr();
41 Expr->print(OS, MAI);
42 OS << ')';
45 void LanaiMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
46 Streamer.visitUsedExpr(*getSubExpr());
49 bool LanaiMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
50 const MCAsmLayout *Layout,
51 const MCFixup *Fixup) const {
52 if (!getSubExpr()->evaluateAsRelocatable(Res, Layout, Fixup))
53 return false;
55 Res =
56 MCValue::get(Res.getSymA(), Res.getSymB(), Res.getConstant(), getKind());
58 return true;