10b57cec5SDimitry Andric //===-- AVRTargetMachine.h - Define TargetMachine for AVR -------*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file declares the AVR specific subclass of TargetMachine. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_AVR_TARGET_MACHINE_H 140b57cec5SDimitry Andric #define LLVM_AVR_TARGET_MACHINE_H 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric #include "llvm/IR/DataLayout.h" 170b57cec5SDimitry Andric #include "llvm/Target/TargetMachine.h" 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric #include "AVRFrameLowering.h" 200b57cec5SDimitry Andric #include "AVRISelLowering.h" 210b57cec5SDimitry Andric #include "AVRInstrInfo.h" 220b57cec5SDimitry Andric #include "AVRSelectionDAGInfo.h" 230b57cec5SDimitry Andric #include "AVRSubtarget.h" 240b57cec5SDimitry Andric 25bdd1243dSDimitry Andric #include <optional> 26bdd1243dSDimitry Andric 270b57cec5SDimitry Andric namespace llvm { 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric /// A generic AVR implementation. 300b57cec5SDimitry Andric class AVRTargetMachine : public LLVMTargetMachine { 310b57cec5SDimitry Andric public: 320b57cec5SDimitry Andric AVRTargetMachine(const Target &T, const Triple &TT, StringRef CPU, 330b57cec5SDimitry Andric StringRef FS, const TargetOptions &Options, 34bdd1243dSDimitry Andric std::optional<Reloc::Model> RM, 35*5f757f3fSDimitry Andric std::optional<CodeModel::Model> CM, CodeGenOptLevel OL, 36bdd1243dSDimitry Andric bool JIT); 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric const AVRSubtarget *getSubtargetImpl() const; 390b57cec5SDimitry Andric const AVRSubtarget *getSubtargetImpl(const Function &) const override; 400b57cec5SDimitry Andric 410b57cec5SDimitry Andric TargetLoweringObjectFile *getObjFileLowering() const override { 420b57cec5SDimitry Andric return this->TLOF.get(); 430b57cec5SDimitry Andric } 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric TargetPassConfig *createPassConfig(PassManagerBase &PM) override; 460b57cec5SDimitry Andric 47bdd1243dSDimitry Andric MachineFunctionInfo * 48bdd1243dSDimitry Andric createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, 49bdd1243dSDimitry Andric const TargetSubtargetInfo *STI) const override; 50bdd1243dSDimitry Andric 51bdd1243dSDimitry Andric bool isNoopAddrSpaceCast(unsigned SrcAs, unsigned DestAs) const override { 52bdd1243dSDimitry Andric // While AVR has different address spaces, they are all represented by 53bdd1243dSDimitry Andric // 16-bit pointers that can be freely casted between (of course, a pointer 54bdd1243dSDimitry Andric // must be cast back to its original address space to be dereferenceable). 55bdd1243dSDimitry Andric // To be safe, also check the pointer size in case we implement __memx 56bdd1243dSDimitry Andric // pointers. 57bdd1243dSDimitry Andric return getPointerSize(SrcAs) == getPointerSize(DestAs); 58bdd1243dSDimitry Andric } 59bdd1243dSDimitry Andric 600b57cec5SDimitry Andric private: 610b57cec5SDimitry Andric std::unique_ptr<TargetLoweringObjectFile> TLOF; 620b57cec5SDimitry Andric AVRSubtarget SubTarget; 630b57cec5SDimitry Andric }; 640b57cec5SDimitry Andric 650b57cec5SDimitry Andric } // end namespace llvm 660b57cec5SDimitry Andric 670b57cec5SDimitry Andric #endif // LLVM_AVR_TARGET_MACHINE_H 68