Files
clang-p2996/llvm/lib/Target/CSKY/MCTargetDesc/CSKYELFObjectWriter.cpp
Zi Xuan Wu ec17c4f075 [CSKY 3/n] Add bare-bones C-SKY MCTargetDesc
Add basis of CSKY MCTargetDesc and it's enough to compile and link but doesn't yet do anything particularly useful.
Once an ASM parser and printer are added in the next two patches, the whole thing can be usefully tested.

Differential Revision: https://reviews.llvm.org/D93372
2020-12-22 11:32:39 +08:00

46 lines
1.4 KiB
C++

//===-- CSKYELFObjectWriter.cpp - CSKY ELF Writer -------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "CSKYMCTargetDesc.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCObjectWriter.h"
#define DEBUG_TYPE "csky-elf-object-writer"
using namespace llvm;
namespace {
class CSKYELFObjectWriter : public MCELFObjectTargetWriter {
public:
CSKYELFObjectWriter(uint8_t OSABI = 0)
: MCELFObjectTargetWriter(false, OSABI, ELF::EM_CSKY, true){};
~CSKYELFObjectWriter() {}
unsigned getRelocType(MCContext &Ctx, const MCValue &Target,
const MCFixup &Fixup, bool IsPCRel) const override;
};
} // namespace
unsigned CSKYELFObjectWriter::getRelocType(MCContext &Ctx,
const MCValue &Target,
const MCFixup &Fixup,
bool IsPCRel) const {
// Determine the type of the relocation.
switch ((unsigned)Fixup.getKind()) {
default:
llvm_unreachable("invalid fixup kind!");
}
}
std::unique_ptr<MCObjectTargetWriter> llvm::createCSKYELFObjectWriter() {
return std::make_unique<CSKYELFObjectWriter>();
}