From: Reid Spencer
This is an overloaded intrinsic. You can use llvm.part.set +on any integer bit width. +
+ declare i17 @llvm.part.set.i17.i17.i9 (i17 %val, i9 %repl, i32 %lo, i32 %hi) + declare i29 @llvm.part.set.i29.i29.i9 (i29 %val, i9 %repl, i32 %lo, i32 %hi) ++ +
The 'llvm.part.set' family of intrinsic functions replaces a range +of bits in an integer value with another integer value. It returns the integer +with the replaced bits.
+ +The first argument, %val and the result may be integer types of +any bit width but they must have the same bit width. %val is the value +whose bits will be replaced. The second argument, %repl may be an +integer of any bit width. The third and fourth arguments must be i32 +type since they specify only a bit index.
+ +The operation of the 'llvm.part.set' intrinsic has two modes +of operation: forwards and reverse. If %lo is greater than +%hi then the intrinsic operates in reverse mode. Otherwise it +operates in forward mode.
+For both modes, the %repl value is prepared for use by either +truncating it down to the size of the replacement area or zero extending it +up to that size.
+In forward mode, the bits between %lo and %hi (inclusive) +are replaced with corresponding bits from %repl. That is the 0th bit +in %repl replaces the %loth bit in %val and etc. up +to the %hith bit. +
In reverse mode, a similar computation is made except that the bits replaced +wrap around to include both the highest and lowest bits. For example, if a +16 bit value is being replaced then %lo=8 and %hi=4 would +cause these bits to be set: 0xFF1F
. ++ llvm.part.set(0xFFFF, 0, Y, 4, 7) -> 0xFF0F + llvm.part.set(0xFFFF, 0, Y, 7, 4) -> 0x0060 + llvm.part.set(0xFFFF, 0, Y, 8, 3) -> 0x00F0 + llvm.part.set(0xFFFF, 0, Y, 3, 8) -> 0xFE07 +