1 //===-- M68kFixupKinds.h - M68k Specific Fixup Entries ----------*- C++ -*-===//
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 /// \file
10 /// This file contains M68k specific fixup entries.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_M68k_MCTARGETDESC_M68kFIXUPKINDS_H
15 #define LLVM_LIB_TARGET_M68k_MCTARGETDESC_M68kFIXUPKINDS_H
16 
17 #include "llvm/MC/MCFixup.h"
18 
19 namespace llvm {
20 static inline unsigned getFixupKindLog2Size(unsigned Kind) {
21   switch (Kind) {
22   case FK_PCRel_1:
23   case FK_SecRel_1:
24   case FK_Data_1:
25     return 0;
26   case FK_PCRel_2:
27   case FK_SecRel_2:
28   case FK_Data_2:
29     return 1;
30   case FK_PCRel_4:
31   case FK_SecRel_4:
32   case FK_Data_4:
33     return 2;
34   }
35   llvm_unreachable("invalid fixup kind!");
36 }
37 
38 static inline MCFixupKind getFixupForSize(unsigned Size, bool isPCRel) {
39   switch (Size) {
40   case 8:
41     return isPCRel ? FK_PCRel_1 : FK_Data_1;
42   case 16:
43     return isPCRel ? FK_PCRel_2 : FK_Data_2;
44   case 32:
45     return isPCRel ? FK_PCRel_4 : FK_Data_4;
46   case 64:
47     return isPCRel ? FK_PCRel_8 : FK_Data_8;
48   }
49   llvm_unreachable("Invalid generic fixup size!");
50 }
51 
52 } // namespace llvm
53 
54 #endif // LLVM_LIB_TARGET_M68k_MCTARGETDESC_M68kFIXUPKINDS_H
55