Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / MC / MCValue.cpp
blobb6bcec9b2ca078a585c7b6cbaaf203d5e0e169ec
1 //===- lib/MC/MCValue.cpp - MCValue implementation ------------------------===//
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 "llvm/MC/MCValue.h"
10 #include "llvm/Config/llvm-config.h"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/Support/Debug.h"
13 #include "llvm/Support/ErrorHandling.h"
14 #include "llvm/Support/raw_ostream.h"
16 using namespace llvm;
18 void MCValue::print(raw_ostream &OS) const {
19 if (isAbsolute()) {
20 OS << getConstant();
21 return;
24 // FIXME: prints as a number, which isn't ideal. But the meaning will be
25 // target-specific anyway.
26 if (getRefKind())
27 OS << ':' << getRefKind() << ':';
29 OS << *getSymA();
31 if (getSymB()) {
32 OS << " - ";
33 OS << *getSymB();
36 if (getConstant())
37 OS << " + " << getConstant();
40 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
41 LLVM_DUMP_METHOD void MCValue::dump() const {
42 print(dbgs());
44 #endif
46 MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const {
47 const MCSymbolRefExpr *B = getSymB();
48 if (B) {
49 if (B->getKind() != MCSymbolRefExpr::VK_None)
50 llvm_unreachable("unsupported");
53 const MCSymbolRefExpr *A = getSymA();
54 if (!A)
55 return MCSymbolRefExpr::VK_None;
57 return A->getKind();