From 233ed51cf53d590d3f52d5becff95317dbf73657 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Thu, 5 Sep 2024 15:57:20 +0200 Subject: [PATCH] [LLD][COFF][NFC] Use is64Bit in Baserel::getDefaultType. (#107378) In preparation for ARM64EC support. Also make it static. --- lld/COFF/Chunks.cpp | 11 +---------- lld/COFF/Chunks.h | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp index 386012e3ce8237..060eb6c32004d2 100644 --- a/lld/COFF/Chunks.cpp +++ b/lld/COFF/Chunks.cpp @@ -1000,16 +1000,7 @@ void BaserelChunk::writeTo(uint8_t *buf) const { } uint8_t Baserel::getDefaultType(llvm::COFF::MachineTypes machine) { - switch (machine) { - case AMD64: - case ARM64: - return IMAGE_REL_BASED_DIR64; - case I386: - case ARMNT: - return IMAGE_REL_BASED_HIGHLOW; - default: - llvm_unreachable("unknown machine type"); - } + return is64Bit(machine) ? IMAGE_REL_BASED_DIR64 : IMAGE_REL_BASED_HIGHLOW; } MergeChunk::MergeChunk(uint32_t alignment) diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h index 8ccd05b21af7b5..30e5b538c352ea 100644 --- a/lld/COFF/Chunks.h +++ b/lld/COFF/Chunks.h @@ -713,7 +713,7 @@ class Baserel { Baserel(uint32_t v, uint8_t ty) : rva(v), type(ty) {} explicit Baserel(uint32_t v, llvm::COFF::MachineTypes machine) : Baserel(v, getDefaultType(machine)) {} - uint8_t getDefaultType(llvm::COFF::MachineTypes machine); + static uint8_t getDefaultType(llvm::COFF::MachineTypes machine); uint32_t rva; uint8_t type;