forked from OSchip/llvm-project
[AVR] Make helper functions static. NFC.
This commit is contained in:
parent
5087ace651
commit
caef4a81c9
|
@ -34,8 +34,9 @@ namespace adjust {
|
|||
|
||||
using namespace llvm;
|
||||
|
||||
void signed_width(unsigned Width, uint64_t Value, std::string Description,
|
||||
const MCFixup &Fixup, MCContext *Ctx = nullptr) {
|
||||
static void signed_width(unsigned Width, uint64_t Value,
|
||||
std::string Description, const MCFixup &Fixup,
|
||||
MCContext *Ctx = nullptr) {
|
||||
if (!isIntN(Width, Value)) {
|
||||
std::string Diagnostic = "out of range " + Description;
|
||||
|
||||
|
@ -53,8 +54,9 @@ void signed_width(unsigned Width, uint64_t Value, std::string Description,
|
|||
}
|
||||
}
|
||||
|
||||
void unsigned_width(unsigned Width, uint64_t Value, std::string Description,
|
||||
const MCFixup &Fixup, MCContext *Ctx = nullptr) {
|
||||
static void unsigned_width(unsigned Width, uint64_t Value,
|
||||
std::string Description, const MCFixup &Fixup,
|
||||
MCContext *Ctx = nullptr) {
|
||||
if (!isUIntN(Width, Value)) {
|
||||
std::string Diagnostic = "out of range " + Description;
|
||||
|
||||
|
@ -72,7 +74,7 @@ void unsigned_width(unsigned Width, uint64_t Value, std::string Description,
|
|||
}
|
||||
|
||||
/// Adjusts the value of a branch target before fixup application.
|
||||
void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
// We have one extra bit of precision because the value is rightshifted by
|
||||
// one.
|
||||
|
@ -83,8 +85,8 @@ void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
|||
}
|
||||
|
||||
/// Adjusts the value of a relative branch target before fixup application.
|
||||
void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
static void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup,
|
||||
uint64_t &Value, MCContext *Ctx = nullptr) {
|
||||
// We have one extra bit of precision because the value is rightshifted by
|
||||
// one.
|
||||
signed_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx);
|
||||
|
@ -101,7 +103,7 @@ void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
|||
/// 1001 kkkk 010k kkkk kkkk kkkk 111k kkkk
|
||||
///
|
||||
/// Offset of 0 (so the result is left shifted by 3 bits before application).
|
||||
void fixup_call(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void fixup_call(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
adjustBranch(Size, Fixup, Value, Ctx);
|
||||
|
||||
|
@ -117,7 +119,7 @@ void fixup_call(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
|||
/// Resolves to:
|
||||
/// 0000 00kk kkkk k000
|
||||
/// Offset of 0 (so the result is left shifted by 3 bits before application).
|
||||
void fixup_7_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void fixup_7_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
adjustRelativeBranch(Size, Fixup, Value, Ctx);
|
||||
|
||||
|
@ -131,7 +133,7 @@ void fixup_7_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
|||
/// Resolves to:
|
||||
/// 0000 kkkk kkkk kkkk
|
||||
/// Offset of 0 (so the result isn't left-shifted before application).
|
||||
void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
adjustRelativeBranch(Size, Fixup, Value, Ctx);
|
||||
|
||||
|
@ -144,7 +146,7 @@ void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
|||
///
|
||||
/// Resolves to:
|
||||
/// 0000 0000 kk00 kkkk
|
||||
void fixup_6_adiw(const MCFixup &Fixup, uint64_t &Value,
|
||||
static void fixup_6_adiw(const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
unsigned_width(6, Value, std::string("immediate"), Fixup, Ctx);
|
||||
|
||||
|
@ -155,7 +157,7 @@ void fixup_6_adiw(const MCFixup &Fixup, uint64_t &Value,
|
|||
///
|
||||
/// Resolves to:
|
||||
/// 0000 0000 AAAA A000
|
||||
void fixup_port5(const MCFixup &Fixup, uint64_t &Value,
|
||||
static void fixup_port5(const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
unsigned_width(5, Value, std::string("port number"), Fixup, Ctx);
|
||||
|
||||
|
@ -168,7 +170,7 @@ void fixup_port5(const MCFixup &Fixup, uint64_t &Value,
|
|||
///
|
||||
/// Resolves to:
|
||||
/// 1011 0AAd dddd AAAA
|
||||
void fixup_port6(const MCFixup &Fixup, uint64_t &Value,
|
||||
static void fixup_port6(const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
unsigned_width(6, Value, std::string("port number"), Fixup, Ctx);
|
||||
|
||||
|
@ -177,9 +179,7 @@ void fixup_port6(const MCFixup &Fixup, uint64_t &Value,
|
|||
|
||||
/// Adjusts a program memory address.
|
||||
/// This is a simple right-shift.
|
||||
void pm(uint64_t &Value) {
|
||||
Value >>= 1;
|
||||
}
|
||||
static void pm(uint64_t &Value) { Value >>= 1; }
|
||||
|
||||
/// Fixups relating to the LDI instruction.
|
||||
namespace ldi {
|
||||
|
@ -189,7 +189,7 @@ namespace ldi {
|
|||
/// Resolves to:
|
||||
/// 0000 KKKK 0000 KKKK
|
||||
/// Offset of 0 (so the result isn't left-shifted before application).
|
||||
void fixup(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void fixup(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
uint64_t upper = Value & 0xf0;
|
||||
uint64_t lower = Value & 0x0f;
|
||||
|
@ -197,27 +197,27 @@ void fixup(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
|||
Value = (upper << 4) | lower;
|
||||
}
|
||||
|
||||
void neg(uint64_t &Value) { Value *= -1; }
|
||||
static void neg(uint64_t &Value) { Value *= -1; }
|
||||
|
||||
void lo8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void lo8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
Value &= 0xff;
|
||||
ldi::fixup(Size, Fixup, Value, Ctx);
|
||||
}
|
||||
|
||||
void hi8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void hi8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
Value = (Value & 0xff00) >> 8;
|
||||
ldi::fixup(Size, Fixup, Value, Ctx);
|
||||
}
|
||||
|
||||
void hh8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void hh8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
Value = (Value & 0xff0000) >> 16;
|
||||
ldi::fixup(Size, Fixup, Value, Ctx);
|
||||
}
|
||||
|
||||
void ms8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
static void ms8(unsigned Size, const MCFixup &Fixup, uint64_t &Value,
|
||||
MCContext *Ctx = nullptr) {
|
||||
Value = (Value & 0xff000000) >> 24;
|
||||
ldi::fixup(Size, Fixup, Value, Ctx);
|
||||
|
|
Loading…
Reference in New Issue