1 //===-- M68kMemOperandPrinter.h - Memory operands printing ------*- 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 memory operand printing logics shared between AsmPrinter 11 // and MCInstPrinter. 12 /// 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_LIB_TARGET_M68K_MEMOPERANDPRINTER_M68KINSTPRINTER_H 16 #define LLVM_LIB_TARGET_M68K_MEMOPERANDPRINTER_M68KINSTPRINTER_H 17 18 #include "M68kBaseInfo.h" 19 20 #include "llvm/Support/raw_ostream.h" 21 22 namespace llvm { 23 template <class Derived, typename InstTy> class M68kMemOperandPrinter { 24 Derived &impl() { return *static_cast<Derived *>(this); } 25 26 protected: 27 void printARIMem(const InstTy *MI, unsigned OpNum, raw_ostream &O) { 28 O << '('; 29 impl().printOperand(MI, OpNum, O); 30 O << ')'; 31 } 32 33 void printARIPIMem(const InstTy *MI, unsigned OpNum, raw_ostream &O) { 34 O << "("; 35 impl().printOperand(MI, OpNum, O); 36 O << ")+"; 37 } 38 39 void printARIPDMem(const InstTy *MI, unsigned OpNum, raw_ostream &O) { 40 O << "-("; 41 impl().printOperand(MI, OpNum, O); 42 O << ")"; 43 } 44 45 void printARIDMem(const InstTy *MI, unsigned OpNum, raw_ostream &O) { 46 O << '('; 47 impl().printDisp(MI, OpNum + M68k::MemDisp, O); 48 O << ','; 49 impl().printOperand(MI, OpNum + M68k::MemBase, O); 50 O << ')'; 51 } 52 53 void printARIIMem(const InstTy *MI, unsigned OpNum, raw_ostream &O) { 54 O << '('; 55 impl().printDisp(MI, OpNum + M68k::MemDisp, O); 56 O << ','; 57 impl().printOperand(MI, OpNum + M68k::MemBase, O); 58 O << ','; 59 impl().printOperand(MI, OpNum + M68k::MemIndex, O); 60 O << ')'; 61 } 62 63 void printPCDMem(const InstTy *MI, uint64_t Address, unsigned OpNum, 64 raw_ostream &O) { 65 O << '('; 66 impl().printDisp(MI, OpNum + M68k::PCRelDisp, O); 67 O << ",%pc)"; 68 } 69 70 void printPCIMem(const InstTy *MI, uint64_t Address, unsigned OpNum, 71 raw_ostream &O) { 72 O << '('; 73 impl().printDisp(MI, OpNum + M68k::PCRelDisp, O); 74 O << ",%pc,"; 75 impl().printOperand(MI, OpNum + M68k::PCRelIndex, O); 76 O << ')'; 77 } 78 }; 79 } // end namespace llvm 80 #endif 81