Path: blob/main/contrib/llvm-project/llvm/lib/Target/SPIRV/SPIRVISelLowering.h
35269 views
//===-- SPIRVISelLowering.h - SPIR-V DAG Lowering Interface -----*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file defines the interfaces that SPIR-V uses to lower LLVM code into a9// selection DAG.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVISELLOWERING_H14#define LLVM_LIB_TARGET_SPIRV_SPIRVISELLOWERING_H1516#include "SPIRVGlobalRegistry.h"17#include "llvm/CodeGen/TargetLowering.h"18#include <set>1920namespace llvm {21class SPIRVSubtarget;2223class SPIRVTargetLowering : public TargetLowering {24const SPIRVSubtarget &STI;2526// Record of already processed machine functions27mutable std::set<const MachineFunction *> ProcessedMF;2829public:30explicit SPIRVTargetLowering(const TargetMachine &TM,31const SPIRVSubtarget &ST)32: TargetLowering(TM), STI(ST) {}3334// Stop IRTranslator breaking up FMA instrs to preserve types information.35bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,36EVT) const override {37return true;38}3940// prevent creation of jump tables41bool areJTsAllowed(const Function *) const override { return false; }4243// This is to prevent sexts of non-i64 vector indices which are generated44// within general IRTranslator hence type generation for it is omitted.45MVT getVectorIdxTy(const DataLayout &DL) const override {46return MVT::getIntegerVT(32);47}48unsigned getNumRegistersForCallingConv(LLVMContext &Context,49CallingConv::ID CC,50EVT VT) const override;51MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC,52EVT VT) const override;53bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,54MachineFunction &MF,55unsigned Intrinsic) const override;5657std::pair<unsigned, const TargetRegisterClass *>58getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,59StringRef Constraint, MVT VT) const override;60unsigned61getNumRegisters(LLVMContext &Context, EVT VT,62std::optional<MVT> RegisterVT = std::nullopt) const override {63return 1;64}6566// Call the default implementation and finalize target lowering by inserting67// extra instructions required to preserve validity of SPIR-V code imposed by68// the standard.69void finalizeLowering(MachineFunction &MF) const override;7071MVT getPreferredSwitchConditionType(LLVMContext &Context,72EVT ConditionVT) const override {73return ConditionVT.getSimpleVT();74}75};76} // namespace llvm7778#endif // LLVM_LIB_TARGET_SPIRV_SPIRVISELLOWERING_H798081