1 //===-- MBlazeELFWriterInfo.cpp - ELF Writer Info for the MBlaze backend --===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements ELF writer information for the MBlaze backend.
12 //===----------------------------------------------------------------------===//
14 #include "MBlazeELFWriterInfo.h"
15 #include "MBlazeRelocations.h"
16 #include "llvm/Function.h"
17 #include "llvm/Support/ErrorHandling.h"
18 #include "llvm/Target/TargetData.h"
19 #include "llvm/Target/TargetMachine.h"
23 //===----------------------------------------------------------------------===//
24 // Implementation of the MBlazeELFWriterInfo class
25 //===----------------------------------------------------------------------===//
27 MBlazeELFWriterInfo::MBlazeELFWriterInfo(TargetMachine &TM)
28 : TargetELFWriterInfo(TM.getTargetData()->getPointerSizeInBits() == 64,
29 TM.getTargetData()->isLittleEndian()) {
32 MBlazeELFWriterInfo::~MBlazeELFWriterInfo() {}
34 unsigned MBlazeELFWriterInfo::getRelocationType(unsigned MachineRelTy) const {
35 switch (MachineRelTy) {
36 case MBlaze::reloc_pcrel_word:
37 return R_MICROBLAZE_64_PCREL;
38 case MBlaze::reloc_absolute_word:
39 return R_MICROBLAZE_NONE;
41 llvm_unreachable("unknown mblaze machine relocation type");
46 long int MBlazeELFWriterInfo::getDefaultAddendForRelTy(unsigned RelTy,
47 long int Modifier) const {
49 case R_MICROBLAZE_32_PCREL:
54 llvm_unreachable("unknown mblaze relocation type");
59 unsigned MBlazeELFWriterInfo::getRelocationTySize(unsigned RelTy) const {
60 // FIXME: Most of these sizes are guesses based on the name
63 case R_MICROBLAZE_32_PCREL:
64 case R_MICROBLAZE_32_PCREL_LO:
65 case R_MICROBLAZE_32_LO:
66 case R_MICROBLAZE_SRO32:
67 case R_MICROBLAZE_SRW32:
68 case R_MICROBLAZE_32_SYM_OP_SYM:
69 case R_MICROBLAZE_GOTOFF_32:
72 case R_MICROBLAZE_64_PCREL:
74 case R_MICROBLAZE_GOTPC_64:
75 case R_MICROBLAZE_GOT_64:
76 case R_MICROBLAZE_PLT_64:
77 case R_MICROBLAZE_GOTOFF_64:
84 bool MBlazeELFWriterInfo::isPCRelativeRel(unsigned RelTy) const {
85 // FIXME: Most of these are guesses based on the name
87 case R_MICROBLAZE_32_PCREL:
88 case R_MICROBLAZE_64_PCREL:
89 case R_MICROBLAZE_32_PCREL_LO:
90 case R_MICROBLAZE_GOTPC_64:
97 unsigned MBlazeELFWriterInfo::getAbsoluteLabelMachineRelTy() const {
98 return MBlaze::reloc_absolute_word;
101 long int MBlazeELFWriterInfo::computeRelocation(unsigned SymOffset,
103 unsigned RelTy) const {
104 if (RelTy == R_MICROBLAZE_32_PCREL || R_MICROBLAZE_64_PCREL)
105 return SymOffset - (RelOffset + 4);
107 assert("computeRelocation unknown for this relocation type");