From 703c6684d103f14193411b589eaa0e0b1e1189f0 Mon Sep 17 00:00:00 2001 From: Sahnvour Date: Mon, 19 Nov 2018 22:22:21 +0100 Subject: Crash fixes and small improvements to inline asm. (#1756) * codegen: LLVMConstInlineAsm is deprecated. * codegen: replace commas in asm constraint strings by pipes as required by LLVM. * ir: enforce usage of '=' constraint modifier for inline assembly outputs. Others are not currently supported and this was just asserted alter in `ir_render_asm`. * asm: forbid comptime_int/floats as inputs in favor of explicitely sized constants. Fixes a crash due to comptime_int/floats having no type_ref. * asm: handle inputs with integers of <8 or non power of 2 bitsize. We widen them to the next highest power of two. --- src/buffer.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/buffer.hpp') diff --git a/src/buffer.hpp b/src/buffer.hpp index 8155df87a1..afe9fd8a91 100644 --- a/src/buffer.hpp +++ b/src/buffer.hpp @@ -181,5 +181,15 @@ static inline Slice buf_to_slice(Buf *buf) { return Slice{reinterpret_cast(buf_ptr(buf)), buf_len(buf)}; } +static inline void buf_replace(Buf* buf, char from, char to) { + const size_t count = buf_len(buf); + char* ptr = buf_ptr(buf); + for (size_t i = 0; i < count; ++i) { + char& l = ptr[i]; + if (l == from) + l = to; + } +} + #endif -- cgit v1.2.3