Path: blob/main/contrib/llvm-project/llvm/lib/Target/SPIRV/SPIRVInlineAsmLowering.cpp
35268 views
//===--- SPIRVInlineAsmLowering.cpp - Inline Asm lowering -------*- 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 implements the lowering of LLVM inline asm calls to machine code9// calls for GlobalISel.10//11//===----------------------------------------------------------------------===//1213#include "SPIRVInlineAsmLowering.h"14#include "SPIRVSubtarget.h"15#include "llvm/IR/IntrinsicInst.h"16#include "llvm/IR/IntrinsicsSPIRV.h"1718using namespace llvm;1920SPIRVInlineAsmLowering::SPIRVInlineAsmLowering(const SPIRVTargetLowering &TLI)21: InlineAsmLowering(&TLI) {}2223bool SPIRVInlineAsmLowering::lowerAsmOperandForConstraint(24Value *Val, StringRef Constraint, std::vector<MachineOperand> &Ops,25MachineIRBuilder &MIRBuilder) const {26Value *ValOp = nullptr;27if (isa<ConstantInt>(Val)) {28ValOp = Val;29} else if (ConstantFP *CFP = dyn_cast<ConstantFP>(Val)) {30Ops.push_back(MachineOperand::CreateFPImm(CFP));31return true;32} else if (auto *II = dyn_cast<IntrinsicInst>(Val)) {33if (II->getIntrinsicID() == Intrinsic::spv_track_constant) {34if (isa<ConstantInt>(II->getOperand(0))) {35ValOp = II->getOperand(0);36} else if (ConstantFP *CFP = dyn_cast<ConstantFP>(II->getOperand(0))) {37Ops.push_back(MachineOperand::CreateFPImm(CFP));38return true;39}40}41}42return ValOp ? InlineAsmLowering::lowerAsmOperandForConstraint(43ValOp, Constraint, Ops, MIRBuilder)44: false;45}464748