From 3034ae5878f2b1f3216ab1a7d2706edf27c8ae4c Mon Sep 17 00:00:00 2001 From: Daniel Schemmel Date: Wed, 28 Jun 2023 22:37:05 +0000 Subject: Combine all `ConstantExpr::toMemory` cases into one. Note that (as it did previously), this relies on the native types having the same internal representation as the ApInt type. --- lib/Expr/Expr.cpp | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp index 2026a07b..7feba8ab 100644 --- a/lib/Expr/Expr.cpp +++ b/lib/Expr/Expr.cpp @@ -363,19 +363,7 @@ ref ConstantExpr::fromMemory(void *address, Width width) { void ConstantExpr::toMemory(void *address) { auto width = getWidth(); - switch (width) { - default: assert(0 && "invalid type"); - case Expr::Bool: *(( uint8_t*) address) = getZExtValue(1); break; - case Expr::Int8: *(( uint8_t*) address) = getZExtValue(8); break; - case Expr::Int16: *((uint16_t*) address) = getZExtValue(16); break; - case Expr::Int32: *((uint32_t*) address) = getZExtValue(32); break; - case Expr::Int64: *((uint64_t*) address) = getZExtValue(64); break; - case Expr::Fl80: - case Expr::Int128: - case Expr::Int256: - case Expr::Int512: - std::memcpy(address, value.getRawData(), width / 8); - } + std::memcpy(address, value.getRawData(), (width + 7) / 8); } void ConstantExpr::toString(std::string &Res, unsigned radix) const { -- cgit 1.4.1