forked from llvm/clangir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR] introduce CIR floating-point types (llvm#385)
This PR adds a dedicated `cir.float` type for representing floating-point types. There are several issues linked to this PR: llvm#5, llvm#78, and llvm#90.
- Loading branch information
Showing
55 changed files
with
937 additions
and
617 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//===- CIRFPTypeInterface.h - Interface for CIR FP types -------*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===---------------------------------------------------------------------===// | ||
// | ||
// Defines the interface to generically handle CIR floating-point types. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H | ||
#define CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H | ||
|
||
#include "mlir/IR/Types.h" | ||
#include "llvm/ADT/APFloat.h" | ||
|
||
/// Include the tablegen'd interface declarations. | ||
#include "clang/CIR/Interfaces/CIRFPTypeInterface.h.inc" | ||
|
||
#endif // CLANG_INTERFACES_CIR_CIR_FPTYPEINTERFACE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===- CIRFPTypeInterface.td - CIR FP Interface Definitions -----*- C++ -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE | ||
#define MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE | ||
|
||
include "mlir/IR/OpBase.td" | ||
|
||
def CIRFPTypeInterface : TypeInterface<"CIRFPTypeInterface"> { | ||
let description = [{ | ||
Contains helper functions to query properties about a floating-point type. | ||
}]; | ||
let cppNamespace = "::mlir::cir"; | ||
|
||
let methods = [ | ||
InterfaceMethod<[{ | ||
Returns the bit width of this floating-point type. | ||
}], | ||
/*retTy=*/"unsigned", | ||
/*methodName=*/"getWidth", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/[{ | ||
return llvm::APFloat::semanticsSizeInBits($_type.getFloatSemantics()); | ||
}] | ||
>, | ||
InterfaceMethod<[{ | ||
Return the mantissa width. | ||
}], | ||
/*retTy=*/"unsigned", | ||
/*methodName=*/"getFPMantissaWidth", | ||
/*args=*/(ins), | ||
/*methodBody=*/"", | ||
/*defaultImplementation=*/[{ | ||
return llvm::APFloat::semanticsPrecision($_type.getFloatSemantics()); | ||
}] | ||
>, | ||
InterfaceMethod<[{ | ||
Return the float semantics of this floating-point type. | ||
}], | ||
/*retTy=*/"const llvm::fltSemantics &", | ||
/*methodName=*/"getFloatSemantics" | ||
>, | ||
]; | ||
} | ||
|
||
#endif // MLIR_CIR_INTERFACES_CIR_FP_TYPE_INTERFACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.