forked from OSchip/llvm-project
Replace bitwiseCast with llvm::bit_cast
PiperOrigin-RevId: 258986485
This commit is contained in:
parent
e239f9647e
commit
9da6e90e1c
|
@ -28,18 +28,10 @@
|
|||
#include "mlir/IR/Location.h"
|
||||
#include "mlir/Support/LogicalResult.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/bit.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
||||
template <typename Dst, typename Src>
|
||||
inline Dst bitwiseCast(Src source) noexcept {
|
||||
Dst dest;
|
||||
static_assert(sizeof(source) == sizeof(dest),
|
||||
"bitwiseCast requires same source and destination bitwidth");
|
||||
std::memcpy(&dest, &source, sizeof(dest));
|
||||
return dest;
|
||||
}
|
||||
|
||||
namespace {
|
||||
/// A SPIR-V module serializer.
|
||||
///
|
||||
|
@ -219,9 +211,10 @@ LogicalResult Deserializer::processMemoryModel(ArrayRef<uint32_t> operands) {
|
|||
|
||||
module->setAttr(
|
||||
"addressing_model",
|
||||
opBuilder.getI32IntegerAttr(bitwiseCast<int32_t>(operands.front())));
|
||||
module->setAttr("memory_model", opBuilder.getI32IntegerAttr(
|
||||
bitwiseCast<int32_t>(operands.back())));
|
||||
opBuilder.getI32IntegerAttr(llvm::bit_cast<int32_t>(operands.front())));
|
||||
module->setAttr(
|
||||
"memory_model",
|
||||
opBuilder.getI32IntegerAttr(llvm::bit_cast<int32_t>(operands.back())));
|
||||
|
||||
return success();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue