1//===- LLVMFloatIntrinsicOps.cpp - LLVM floating-point intrinsics ---------===//
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// This file defines the ops of op partition `FloatIntrinsic` of the LLVM
10// dialect.
11//
12//===----------------------------------------------------------------------===//
13
14#include "mlir/Dialect/LLVMIR/LLVMFloatIntrinsicOps.h"
15
16#include "IR/LLVMOps.h"
17#include "mlir/IR/DialectImplementation.h"
18
19using namespace mlir;
20using namespace mlir::LLVM;
21
22//===----------------------------------------------------------------------===//
23// SincosOp and ModfOp (intrinsics)
24//===----------------------------------------------------------------------===//
25
26static LogicalResult verifyHomogeneousStructResult(Operation *op,
27 Type operandType,
28 Type resultType) {
29 auto resultStructType =
30 mlir::dyn_cast<mlir::LLVM::LLVMStructType>(Val&: resultType);
31 if (!resultStructType || resultStructType.getBody().size() != 2 ||
32 resultStructType.getBody()[0] != operandType ||
33 resultStructType.getBody()[1] != operandType) {
34 return op->emitOpError(
35 message: "expected result type to be a homogeneous struct with "
36 "two elements matching the operand type, but got ")
37 << resultType;
38 }
39 return success();
40}
41
42LogicalResult LLVM::SincosOp::verify() {
43 return verifyHomogeneousStructResult(op: getOperation(), operandType: getVal().getType(),
44 resultType: getResult().getType());
45}
46
47LogicalResult LLVM::ModfOp::verify() {
48 return verifyHomogeneousStructResult(op: getOperation(), operandType: getVal().getType(),
49 resultType: getResult().getType());
50}
51
52#define GET_OP_CLASSES
53#include "mlir/Dialect/LLVMIR/LLVMFloatIntrinsicOps.cpp.inc"
54