[llvm] 221bc55 - Move AVR-specific MCSymbolRefExpr::VariantKind to AVRMCExpr
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 14 20:29:17 PDT 2025
Author: Fangrui Song
Date: 2025-03-14T20:29:12-07:00
New Revision: 221bc55806db19974537ec59cffb66222902b51e
URL: https://github.com/llvm/llvm-project/commit/221bc55806db19974537ec59cffb66222902b51e
DIFF: https://github.com/llvm/llvm-project/commit/221bc55806db19974537ec59cffb66222902b51e.diff
LOG: Move AVR-specific MCSymbolRefExpr::VariantKind to AVRMCExpr
Note: AVR uses both VK_None and VK_AVR_NONE, which look strange.
Added:
Modified:
llvm/lib/Target/AVR/AVRAsmPrinter.cpp
llvm/lib/Target/AVR/AVRMCInstLower.cpp
llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.h
llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
index deca7d584148c..a63aa54211824 100644
--- a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
+++ b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp
@@ -206,7 +206,7 @@ const MCExpr *AVRAsmPrinter::lowerConstant(const Constant *CV) {
bool IsProgMem = GV->getAddressSpace() == AVR::ProgramMemory;
if (IsProgMem) {
const MCExpr *Expr = MCSymbolRefExpr::create(getSymbol(GV), Ctx);
- return AVRMCExpr::create(AVRMCExpr::VK_AVR_PM, Expr, false, Ctx);
+ return AVRMCExpr::create(AVRMCExpr::VK_PM, Expr, false, Ctx);
}
}
diff --git a/llvm/lib/Target/AVR/AVRMCInstLower.cpp b/llvm/lib/Target/AVR/AVRMCInstLower.cpp
index 56de555671193..47d9073f6eb84 100644
--- a/llvm/lib/Target/AVR/AVRMCInstLower.cpp
+++ b/llvm/lib/Target/AVR/AVRMCInstLower.cpp
@@ -42,21 +42,19 @@ AVRMCInstLower::lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym,
if (TF & AVRII::MO_LO) {
if (IsFunction) {
- Expr =
- AVRMCExpr::create(Subtarget.hasEIJMPCALL() ? AVRMCExpr::VK_AVR_LO8_GS
- : AVRMCExpr::VK_AVR_PM_LO8,
- Expr, IsNegated, Ctx);
+ Expr = AVRMCExpr::create(Subtarget.hasEIJMPCALL() ? AVRMCExpr::VK_LO8_GS
+ : AVRMCExpr::VK_PM_LO8,
+ Expr, IsNegated, Ctx);
} else {
- Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_LO8, Expr, IsNegated, Ctx);
+ Expr = AVRMCExpr::create(AVRMCExpr::VK_LO8, Expr, IsNegated, Ctx);
}
} else if (TF & AVRII::MO_HI) {
if (IsFunction) {
- Expr =
- AVRMCExpr::create(Subtarget.hasEIJMPCALL() ? AVRMCExpr::VK_AVR_HI8_GS
- : AVRMCExpr::VK_AVR_PM_HI8,
- Expr, IsNegated, Ctx);
+ Expr = AVRMCExpr::create(Subtarget.hasEIJMPCALL() ? AVRMCExpr::VK_HI8_GS
+ : AVRMCExpr::VK_PM_HI8,
+ Expr, IsNegated, Ctx);
} else {
- Expr = AVRMCExpr::create(AVRMCExpr::VK_AVR_HI8, Expr, IsNegated, Ctx);
+ Expr = AVRMCExpr::create(AVRMCExpr::VK_HI8, Expr, IsNegated, Ctx);
}
} else if (TF != 0) {
llvm_unreachable("Unknown target flag on symbol operand");
diff --git a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
index 68bd89f624b8a..86481f2496b9d 100644
--- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
+++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp
@@ -447,7 +447,7 @@ bool AVRAsmParser::tryParseExpression(OperandVector &Operands, int64_t offset) {
bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
bool isNegated = false;
- AVRMCExpr::VariantKind ModifierKind = AVRMCExpr::VK_AVR_None;
+ AVRMCExpr::VariantKind ModifierKind = AVRMCExpr::VK_AVR_NONE;
SMLoc S = Parser.getTok().getLoc();
@@ -473,14 +473,14 @@ bool AVRAsmParser::tryParseRelocExpression(OperandVector &Operands) {
StringRef ModifierName = Parser.getTok().getString();
ModifierKind = AVRMCExpr::getKindByName(ModifierName);
- if (ModifierKind != AVRMCExpr::VK_AVR_None) {
+ if (ModifierKind != AVRMCExpr::VK_AVR_NONE) {
Parser.Lex();
Parser.Lex(); // Eat modifier name and parenthesis
if (Parser.getTok().getString() == GENERATE_STUBS &&
Parser.getTok().getKind() == AsmToken::Identifier) {
std::string GSModName = ModifierName.str() + "_" + GENERATE_STUBS;
ModifierKind = AVRMCExpr::getKindByName(GSModName);
- if (ModifierKind != AVRMCExpr::VK_AVR_None)
+ if (ModifierKind != AVRMCExpr::VK_AVR_NONE)
Parser.Lex(); // Eat gs modifier name
}
} else {
@@ -698,7 +698,7 @@ ParseStatus AVRAsmParser::parseLiteralValues(unsigned SizeInBytes, SMLoc L) {
Tokens[1].getKind() == AsmToken::Identifier) {
MCSymbol *Symbol = getContext().getOrCreateSymbol(".text");
AVRStreamer.emitValueForModiferKind(Symbol, SizeInBytes, L,
- AVRMCExpr::VK_AVR_None);
+ AVRMCExpr::VK_AVR_NONE);
return ParseStatus::NoMatch;
}
@@ -707,7 +707,7 @@ ParseStatus AVRAsmParser::parseLiteralValues(unsigned SizeInBytes, SMLoc L) {
StringRef ModifierName = Parser.getTok().getString();
AVRMCExpr::VariantKind ModifierKind =
AVRMCExpr::getKindByName(ModifierName);
- if (ModifierKind != AVRMCExpr::VK_AVR_None) {
+ if (ModifierKind != AVRMCExpr::VK_AVR_NONE) {
Parser.Lex();
Parser.Lex(); // Eat the modifier and parenthesis
} else {
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp
index 1a08980d9df7b..3b00315e92432 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "MCTargetDesc/AVRFixupKinds.h"
+#include "MCTargetDesc/AVRMCExpr.h"
#include "MCTargetDesc/AVRMCTargetDesc.h"
#include "llvm/MC/MCAssembler.h"
@@ -39,42 +40,42 @@ unsigned AVRELFObjectWriter::getRelocType(MCContext &Ctx, const MCValue &Target,
const unsigned Kind = Fixup.getTargetKind();
if (Kind >= FirstLiteralRelocationKind)
return Kind - FirstLiteralRelocationKind;
- MCSymbolRefExpr::VariantKind Modifier = Target.getAccessVariant();
+ auto Modifier = AVRMCExpr::VariantKind(Target.getAccessVariant());
switch ((unsigned)Fixup.getKind()) {
case FK_Data_1:
switch (Modifier) {
default:
llvm_unreachable("Unsupported Modifier");
- case MCSymbolRefExpr::VK_None:
+ case AVRMCExpr::VK_None:
return ELF::R_AVR_8;
- case MCSymbolRefExpr::VK_AVR_DIFF8:
+ case AVRMCExpr::VK_DIFF8:
return ELF::R_AVR_DIFF8;
- case MCSymbolRefExpr::VK_AVR_LO8:
+ case AVRMCExpr::VK_LO8:
return ELF::R_AVR_8_LO8;
- case MCSymbolRefExpr::VK_AVR_HI8:
+ case AVRMCExpr::VK_HI8:
return ELF::R_AVR_8_HI8;
- case MCSymbolRefExpr::VK_AVR_HLO8:
+ case AVRMCExpr::VK_HH8:
return ELF::R_AVR_8_HLO8;
}
case FK_Data_4:
switch (Modifier) {
default:
llvm_unreachable("Unsupported Modifier");
- case MCSymbolRefExpr::VK_None:
+ case AVRMCExpr::VK_None:
return ELF::R_AVR_32;
- case MCSymbolRefExpr::VK_AVR_DIFF32:
+ case AVRMCExpr::VK_DIFF32:
return ELF::R_AVR_DIFF32;
}
case FK_Data_2:
switch (Modifier) {
default:
llvm_unreachable("Unsupported Modifier");
- case MCSymbolRefExpr::VK_None:
+ case AVRMCExpr::VK_None:
return ELF::R_AVR_16;
- case MCSymbolRefExpr::VK_AVR_NONE:
- case MCSymbolRefExpr::VK_AVR_PM:
+ case AVRMCExpr::VK_AVR_NONE:
+ case AVRMCExpr::VK_PM:
return ELF::R_AVR_16_PM;
- case MCSymbolRefExpr::VK_AVR_DIFF16:
+ case AVRMCExpr::VK_DIFF16:
return ELF::R_AVR_DIFF16;
}
case AVR::fixup_32:
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp
index 1ec106ce576b2..b6e692277a230 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCAsmInfo.cpp
@@ -11,20 +11,17 @@
//===----------------------------------------------------------------------===//
#include "AVRMCAsmInfo.h"
+#include "AVRMCExpr.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/TargetParser/Triple.h"
using namespace llvm;
const MCAsmInfo::VariantKindDesc variantKindDescs[] = {
- {MCSymbolRefExpr::VK_AVR_DIFF16, "
diff 16"},
- {MCSymbolRefExpr::VK_AVR_DIFF32, "
diff 32"},
- {MCSymbolRefExpr::VK_AVR_DIFF8, "
diff 8"},
- {MCSymbolRefExpr::VK_AVR_HI8, "hi8"},
- {MCSymbolRefExpr::VK_AVR_HLO8, "hlo8"},
- {MCSymbolRefExpr::VK_AVR_LO8, "lo8"},
- {MCSymbolRefExpr::VK_AVR_NONE, "none"},
- {MCSymbolRefExpr::VK_AVR_PM, "pm"},
+ {AVRMCExpr::VK_DIFF16, "
diff 16"}, {AVRMCExpr::VK_DIFF32, "
diff 32"},
+ {AVRMCExpr::VK_DIFF8, "
diff 8"}, {AVRMCExpr::VK_HI8, "hi8"},
+ {AVRMCExpr::VK_HH8, "hlo8"}, {AVRMCExpr::VK_LO8, "lo8"},
+ {AVRMCExpr::VK_PM, "pm"},
};
AVRMCAsmInfo::AVRMCAsmInfo(const Triple &TT, const MCTargetOptions &Options) {
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.cpp
index 5f2a5a82e41d6..28124be24ef2b 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.cpp
@@ -23,21 +23,23 @@ using namespace llvm;
void AVRMCELFStreamer::emitValueForModiferKind(
const MCSymbol *Sym, unsigned SizeInBytes, SMLoc Loc,
AVRMCExpr::VariantKind ModifierKind) {
- MCSymbolRefExpr::VariantKind Kind = MCSymbolRefExpr::VK_AVR_NONE;
- if (ModifierKind == AVRMCExpr::VK_AVR_None) {
- Kind = MCSymbolRefExpr::VK_AVR_DIFF8;
+ AVRMCExpr::VariantKind Kind = AVRMCExpr::VK_AVR_NONE;
+ if (ModifierKind == AVRMCExpr::VK_AVR_NONE) {
+ Kind = AVRMCExpr::VK_DIFF8;
if (SizeInBytes == SIZE_LONG)
- Kind = MCSymbolRefExpr::VK_AVR_DIFF32;
+ Kind = AVRMCExpr::VK_DIFF32;
else if (SizeInBytes == SIZE_WORD)
- Kind = MCSymbolRefExpr::VK_AVR_DIFF16;
- } else if (ModifierKind == AVRMCExpr::VK_AVR_LO8)
- Kind = MCSymbolRefExpr::VK_AVR_LO8;
- else if (ModifierKind == AVRMCExpr::VK_AVR_HI8)
- Kind = MCSymbolRefExpr::VK_AVR_HI8;
- else if (ModifierKind == AVRMCExpr::VK_AVR_HH8)
- Kind = MCSymbolRefExpr::VK_AVR_HLO8;
- MCELFStreamer::emitValue(MCSymbolRefExpr::create(Sym, Kind, getContext()),
- SizeInBytes, Loc);
+ Kind = AVRMCExpr::VK_DIFF16;
+ } else if (ModifierKind == AVRMCExpr::VK_LO8)
+ Kind = AVRMCExpr::VK_LO8;
+ else if (ModifierKind == AVRMCExpr::VK_HI8)
+ Kind = AVRMCExpr::VK_HI8;
+ else if (ModifierKind == AVRMCExpr::VK_HH8)
+ Kind = AVRMCExpr::VK_HH8;
+ MCELFStreamer::emitValue(
+ MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VariantKind(Kind),
+ getContext()),
+ SizeInBytes, Loc);
}
namespace llvm {
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.h
index 1d05b8d56d930..62148e40ebc2e 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.h
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCELFStreamer.h
@@ -43,7 +43,7 @@ class AVRMCELFStreamer : public MCELFStreamer {
void emitValueForModiferKind(
const MCSymbol *Sym, unsigned SizeInBytes, SMLoc Loc = SMLoc(),
- AVRMCExpr::VariantKind ModifierKind = AVRMCExpr::VK_AVR_None);
+ AVRMCExpr::VariantKind ModifierKind = AVRMCExpr::VK_AVR_NONE);
};
MCStreamer *createAVRELFStreamer(Triple const &TT, MCContext &Context,
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
index 5386df7f4afcd..6d1cb29499980 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.cpp
@@ -21,15 +21,15 @@ const struct ModifierEntry {
const char *const Spelling;
AVRMCExpr::VariantKind VariantKind;
} ModifierNames[] = {
- {"lo8", AVRMCExpr::VK_AVR_LO8}, {"hi8", AVRMCExpr::VK_AVR_HI8},
- {"hh8", AVRMCExpr::VK_AVR_HH8}, // synonym with hlo8
- {"hlo8", AVRMCExpr::VK_AVR_HH8}, {"hhi8", AVRMCExpr::VK_AVR_HHI8},
+ {"lo8", AVRMCExpr::VK_LO8}, {"hi8", AVRMCExpr::VK_HI8},
+ {"hh8", AVRMCExpr::VK_HH8}, // synonym with hlo8
+ {"hlo8", AVRMCExpr::VK_HH8}, {"hhi8", AVRMCExpr::VK_HHI8},
- {"pm", AVRMCExpr::VK_AVR_PM}, {"pm_lo8", AVRMCExpr::VK_AVR_PM_LO8},
- {"pm_hi8", AVRMCExpr::VK_AVR_PM_HI8}, {"pm_hh8", AVRMCExpr::VK_AVR_PM_HH8},
+ {"pm", AVRMCExpr::VK_PM}, {"pm_lo8", AVRMCExpr::VK_PM_LO8},
+ {"pm_hi8", AVRMCExpr::VK_PM_HI8}, {"pm_hh8", AVRMCExpr::VK_PM_HH8},
- {"lo8_gs", AVRMCExpr::VK_AVR_LO8_GS}, {"hi8_gs", AVRMCExpr::VK_AVR_HI8_GS},
- {"gs", AVRMCExpr::VK_AVR_GS},
+ {"lo8_gs", AVRMCExpr::VK_LO8_GS}, {"hi8_gs", AVRMCExpr::VK_HI8_GS},
+ {"gs", AVRMCExpr::VK_GS},
};
} // end of anonymous namespace
@@ -40,7 +40,7 @@ const AVRMCExpr *AVRMCExpr::create(VariantKind Kind, const MCExpr *Expr,
}
void AVRMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
- assert(Kind != VK_AVR_None);
+ assert(Kind != VK_AVR_NONE);
OS << getName() << '(';
if (isNegated())
OS << '-' << '(';
@@ -87,8 +87,8 @@ bool AVRMCExpr::evaluateAsRelocatableImpl(MCValue &Result,
MCSymbolRefExpr::VariantKind Modifier = Sym->getKind();
if (Modifier != MCSymbolRefExpr::VK_None)
return false;
- if (Kind == VK_AVR_PM) {
- Modifier = MCSymbolRefExpr::VK_AVR_PM;
+ if (Kind == VK_PM) {
+ Modifier = MCSymbolRefExpr::VariantKind(AVRMCExpr::VK_PM);
}
Sym = MCSymbolRefExpr::create(&Sym->getSymbol(), Modifier, Context);
@@ -103,43 +103,44 @@ int64_t AVRMCExpr::evaluateAsInt64(int64_t Value) const {
Value *= -1;
switch (Kind) {
- case AVRMCExpr::VK_AVR_LO8:
+ case AVRMCExpr::VK_LO8:
Value &= 0xff;
break;
- case AVRMCExpr::VK_AVR_HI8:
+ case AVRMCExpr::VK_HI8:
Value &= 0xff00;
Value >>= 8;
break;
- case AVRMCExpr::VK_AVR_HH8:
+ case AVRMCExpr::VK_HH8:
Value &= 0xff0000;
Value >>= 16;
break;
- case AVRMCExpr::VK_AVR_HHI8:
+ case AVRMCExpr::VK_HHI8:
Value &= 0xff000000;
Value >>= 24;
break;
- case AVRMCExpr::VK_AVR_PM_LO8:
- case AVRMCExpr::VK_AVR_LO8_GS:
+ case AVRMCExpr::VK_PM_LO8:
+ case AVRMCExpr::VK_LO8_GS:
Value >>= 1; // Program memory addresses must always be shifted by one.
Value &= 0xff;
break;
- case AVRMCExpr::VK_AVR_PM_HI8:
- case AVRMCExpr::VK_AVR_HI8_GS:
+ case AVRMCExpr::VK_PM_HI8:
+ case AVRMCExpr::VK_HI8_GS:
Value >>= 1; // Program memory addresses must always be shifted by one.
Value &= 0xff00;
Value >>= 8;
break;
- case AVRMCExpr::VK_AVR_PM_HH8:
+ case AVRMCExpr::VK_PM_HH8:
Value >>= 1; // Program memory addresses must always be shifted by one.
Value &= 0xff0000;
Value >>= 16;
break;
- case AVRMCExpr::VK_AVR_PM:
- case AVRMCExpr::VK_AVR_GS:
+ case AVRMCExpr::VK_PM:
+ case AVRMCExpr::VK_GS:
Value >>= 1; // Program memory addresses must always be shifted by one.
break;
- case AVRMCExpr::VK_AVR_None:
+ case AVRMCExpr::VK_AVR_NONE:
+ default:
llvm_unreachable("Uninitialized expression.");
}
return static_cast<uint64_t>(Value) & 0xff;
@@ -149,40 +150,40 @@ AVR::Fixups AVRMCExpr::getFixupKind() const {
AVR::Fixups Kind = AVR::Fixups::LastTargetFixupKind;
switch (getKind()) {
- case VK_AVR_LO8:
+ case VK_LO8:
Kind = isNegated() ? AVR::fixup_lo8_ldi_neg : AVR::fixup_lo8_ldi;
break;
- case VK_AVR_HI8:
+ case VK_HI8:
Kind = isNegated() ? AVR::fixup_hi8_ldi_neg : AVR::fixup_hi8_ldi;
break;
- case VK_AVR_HH8:
+ case VK_HH8:
Kind = isNegated() ? AVR::fixup_hh8_ldi_neg : AVR::fixup_hh8_ldi;
break;
- case VK_AVR_HHI8:
+ case VK_HHI8:
Kind = isNegated() ? AVR::fixup_ms8_ldi_neg : AVR::fixup_ms8_ldi;
break;
- case VK_AVR_PM_LO8:
+ case VK_PM_LO8:
Kind = isNegated() ? AVR::fixup_lo8_ldi_pm_neg : AVR::fixup_lo8_ldi_pm;
break;
- case VK_AVR_PM_HI8:
+ case VK_PM_HI8:
Kind = isNegated() ? AVR::fixup_hi8_ldi_pm_neg : AVR::fixup_hi8_ldi_pm;
break;
- case VK_AVR_PM_HH8:
+ case VK_PM_HH8:
Kind = isNegated() ? AVR::fixup_hh8_ldi_pm_neg : AVR::fixup_hh8_ldi_pm;
break;
- case VK_AVR_PM:
- case VK_AVR_GS:
+ case VK_PM:
+ case VK_GS:
Kind = AVR::fixup_16_pm;
break;
- case VK_AVR_LO8_GS:
+ case VK_LO8_GS:
Kind = AVR::fixup_lo8_ldi_gs;
break;
- case VK_AVR_HI8_GS:
+ case VK_HI8_GS:
Kind = AVR::fixup_hi8_ldi_gs;
break;
- case VK_AVR_None:
+ default:
llvm_unreachable("Uninitialized expression");
}
@@ -214,7 +215,7 @@ AVRMCExpr::VariantKind AVRMCExpr::getKindByName(StringRef Name) {
if (Modifier != std::end(ModifierNames)) {
return Modifier->VariantKind;
}
- return VK_AVR_None;
+ return VK_AVR_NONE;
}
} // end of namespace llvm
diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
index 03d3363d85774..08249cb8d170a 100644
--- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
+++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h
@@ -20,21 +20,29 @@ class AVRMCExpr : public MCTargetExpr {
public:
/// Specifies the type of an expression.
enum VariantKind {
- VK_AVR_None = 0,
+ VK_None,
- VK_AVR_HI8, ///< Corresponds to `hi8()`.
- VK_AVR_LO8, ///< Corresponds to `lo8()`.
- VK_AVR_HH8, ///< Corresponds to `hlo8() and hh8()`.
- VK_AVR_HHI8, ///< Corresponds to `hhi8()`.
+ // While not strictly necessary, start at a larger number to avoid confusion
+ // with MCSymbolRefExpr::VariantKind.
+ VK_AVR_NONE = 100,
- VK_AVR_PM, ///< Corresponds to `pm()`, reference to program memory.
- VK_AVR_PM_LO8, ///< Corresponds to `pm_lo8()`.
- VK_AVR_PM_HI8, ///< Corresponds to `pm_hi8()`.
- VK_AVR_PM_HH8, ///< Corresponds to `pm_hh8()`.
+ VK_HI8, ///< Corresponds to `hi8()`.
+ VK_LO8, ///< Corresponds to `lo8()`.
+ VK_HH8, ///< Corresponds to `hlo8() and hh8()`.
+ VK_HHI8, ///< Corresponds to `hhi8()`.
- VK_AVR_LO8_GS, ///< Corresponds to `lo8(gs())`.
- VK_AVR_HI8_GS, ///< Corresponds to `hi8(gs())`.
- VK_AVR_GS, ///< Corresponds to `gs()`.
+ VK_PM, ///< Corresponds to `pm()`, reference to program memory.
+ VK_PM_LO8, ///< Corresponds to `pm_lo8()`.
+ VK_PM_HI8, ///< Corresponds to `pm_hi8()`.
+ VK_PM_HH8, ///< Corresponds to `pm_hh8()`.
+
+ VK_LO8_GS, ///< Corresponds to `lo8(gs())`.
+ VK_HI8_GS, ///< Corresponds to `hi8(gs())`.
+ VK_GS, ///< Corresponds to `gs()`.
+
+ VK_DIFF8,
+ VK_DIFF16,
+ VK_DIFF32,
};
public:
More information about the llvm-commits
mailing list