1//===- SystemZGOFFObjectWriter.cpp - SystemZ GOFF writer ------------------===//
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//===----------------------------------------------------------------------===//
8
9#include "MCTargetDesc/SystemZMCTargetDesc.h"
10#include "SystemZMCAsmInfo.h"
11#include "llvm/MC/MCGOFFObjectWriter.h"
12#include <memory>
13
14using namespace llvm;
15
16namespace {
17class SystemZGOFFObjectWriter : public MCGOFFObjectTargetWriter {
18public:
19 SystemZGOFFObjectWriter();
20
21 unsigned getRelocType(const MCValue &Target,
22 const MCFixup &Fixup) const override;
23};
24} // end anonymous namespace
25
26SystemZGOFFObjectWriter::SystemZGOFFObjectWriter()
27 : MCGOFFObjectTargetWriter() {}
28
29unsigned SystemZGOFFObjectWriter::getRelocType(const MCValue &Target,
30 const MCFixup &Fixup) const {
31 switch (Target.getSpecifier()) {
32 case SystemZ::S_RCon:
33 return Reloc_Type_RCon;
34 case SystemZ::S_VCon:
35 return Reloc_Type_VCon;
36 case SystemZ::S_QCon:
37 return Reloc_Type_QCon;
38 case SystemZ::S_None:
39 if (Fixup.isPCRel())
40 return Reloc_Type_RICon;
41 return Reloc_Type_ACon;
42 }
43 llvm_unreachable("Modifier not supported");
44}
45
46std::unique_ptr<MCObjectTargetWriter> llvm::createSystemZGOFFObjectWriter() {
47 return std::make_unique<SystemZGOFFObjectWriter>();
48}
49