Add runtime sign-extensions to binutils
MODIFY
src/binutils.h
src/binutils.h
#include <cstdint>
#include <vector>
+#include "limits.h"
namespace Ripes {
@@ -15,6 +16,13 @@ inline T signextend(const T x) {
return s.x = x;
}
+// Runtime signextension
+template <typename T>
+inline T signextend(const T x, unsigned B) {
+ int const m = CHAR_BIT * sizeof(T) - B;
+ return (x << m) >> m;
+}
+
/// Checks if an integer fits into the given bit width.
/// from LLVM MathExtras.h
template <unsigned N>

Add runtime sign-extensions to binutils