207
207
< li > < a href ="#int_part_set "> '< tt > llvm.part.set.*</ tt > ' Intrinsic </ a > </ li >
208
208
</ ol >
209
209
</ li >
210
+ < li > < a href ="#int_overflow "> Arithmetic with Overflow Intrinsics</ a >
211
+ < ol >
212
+ < li > < a href ="#int_sadd_ovf "> '< tt > llvm.sadd.with.overflow.*</ tt > Intrinsics</ a > </ li >
213
+ < li > < a href ="#int_uadd_ovf "> '< tt > llvm.uadd.with.overflow.*</ tt > Intrinsics</ a > </ li >
214
+ < li > < a href ="#int_ssub_ovf "> '< tt > llvm.ssub.with.overflow.*</ tt > Intrinsics</ a > </ li >
215
+ < li > < a href ="#int_usub_ovf "> '< tt > llvm.usub.with.overflow.*</ tt > Intrinsics</ a > </ li >
216
+ < li > < a href ="#int_smul_ovf "> '< tt > llvm.smul.with.overflow.*</ tt > Intrinsics</ a > </ li >
217
+ </ ol >
218
+ </ li >
210
219
< li > < a href ="#int_debugger "> Debugger intrinsics</ a > </ li >
211
220
< li > < a href ="#int_eh "> Exception Handling intrinsics</ a > </ li >
212
221
< li > < a href ="#int_trampoline "> Trampoline Intrinsic</ a >
@@ -5573,7 +5582,7 @@ <h5>Syntax:</h5>
5573
5582
< p > This is an overloaded intrinsic. You can use llvm.ctpop on any integer bit
5574
5583
width. Not all targets support all bit widths however.</ p >
5575
5584
< pre >
5576
- declare i8 @llvm.ctpop.i8 (i8 <src>)
5585
+ declare i8 @llvm.ctpop.i8(i8 <src>)
5577
5586
declare i16 @llvm.ctpop.i16(i16 <src>)
5578
5587
declare i32 @llvm.ctpop.i32(i32 <src>)
5579
5588
declare i64 @llvm.ctpop.i64(i64 <src>)
@@ -5753,8 +5762,8 @@ <h5>Overview:</h5>
5753
5762
with the replaced bits.</ p >
5754
5763
5755
5764
< h5 > Arguments:</ h5 >
5756
- < p > The first argument, < tt > %val</ tt > and the result may be integer types of
5757
- any bit width but they must have the same bit width. < tt > %val</ tt > is the value
5765
+ < p > The first argument, < tt > %val</ tt > , and the result may be integer types of
5766
+ any bit width, but they must have the same bit width. < tt > %val</ tt > is the value
5758
5767
whose bits will be replaced. The second argument, < tt > %repl</ tt > may be an
5759
5768
integer of any bit width. The third and fourth arguments must be < tt > i32</ tt >
5760
5769
type since they specify only a bit index.</ p >
@@ -5764,24 +5773,271 @@ <h5>Semantics:</h5>
5764
5773
of operation: forwards and reverse. If < tt > %lo</ tt > is greater than
5765
5774
< tt > %hi</ tt > then the intrinsic operates in reverse mode. Otherwise it
5766
5775
operates in forward mode.</ p >
5776
+
5767
5777
< p > For both modes, the < tt > %repl</ tt > value is prepared for use by either
5768
5778
truncating it down to the size of the replacement area or zero extending it
5769
5779
up to that size.</ p >
5780
+
5770
5781
< p > In forward mode, the bits between < tt > %lo</ tt > and < tt > %hi</ tt > (inclusive)
5771
5782
are replaced with corresponding bits from < tt > %repl</ tt > . That is the 0th bit
5772
5783
in < tt > %repl</ tt > replaces the < tt > %lo</ tt > th bit in < tt > %val</ tt > and etc. up
5773
5784
to the < tt > %hi</ tt > th bit.</ p >
5785
+
5774
5786
< p > In reverse mode, a similar computation is made except that the bits are
5775
5787
reversed. That is, the < tt > 0</ tt > th bit in < tt > %repl</ tt > replaces the
5776
5788
< tt > %hi</ tt > bit in < tt > %val</ tt > and etc. down to the < tt > %lo</ tt > th bit.</ p >
5789
+
5777
5790
< h5 > Examples:</ h5 >
5791
+
5778
5792
< pre >
5779
5793
llvm.part.set(0xFFFF, 0, 4, 7) -> 0xFF0F
5780
5794
llvm.part.set(0xFFFF, 0, 7, 4) -> 0xFF0F
5781
5795
llvm.part.set(0xFFFF, 1, 7, 4) -> 0xFF8F
5782
5796
llvm.part.set(0xFFFF, F, 8, 3) -> 0xFFE7
5783
5797
llvm.part.set(0xFFFF, 0, 3, 8) -> 0xFE07
5784
5798
</ pre >
5799
+
5800
+ </ div >
5801
+
5802
+ <!-- _______________________________________________________________________ -->
5803
+ < div class ="doc_subsubsection ">
5804
+ < a name ="int_sadd_ovf "> '< tt > llvm.sadd.with.overflow.*</ tt > ' Intrinsics</ a >
5805
+ </ div >
5806
+
5807
+ < div class ="doc_text ">
5808
+
5809
+ < h5 > Syntax:</ h5 >
5810
+
5811
+ < p > This is an overloaded intrinsic. You can use < tt > llvm.sadd.with.overflow</ tt >
5812
+ on any integer bit width. However, not all targets support all bit widths.</ p >
5813
+
5814
+ < pre >
5815
+ declare {i16, i1} @llvm.sadd.with.overflow.i16(i16 %a, i16 %b)
5816
+ declare {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
5817
+ declare {i64, i1} @llvm.sadd.with.overflow.i64(i64 %a, i64 %b)
5818
+ </ pre >
5819
+
5820
+ < h5 > Overview:</ h5 >
5821
+
5822
+ < p > The '< tt > llvm.sadd.with.overflow</ tt > ' family of intrinsic functions perform
5823
+ a signed addition of the two arguments, and indicate whether an overflow
5824
+ occurred during the signed summation.</ p >
5825
+
5826
+ < h5 > Arguments:</ h5 >
5827
+
5828
+ < p > The arguments (%a and %b) and the first element of the result structure may
5829
+ be of integer types of any bit width, but they must have the same bit width. The
5830
+ second element of the result structure must be of type < tt > i1</ tt > . < tt > %a</ tt >
5831
+ and < tt > %b</ tt > are the two values that will undergo signed addition.</ p >
5832
+
5833
+ < h5 > Semantics:</ h5 >
5834
+
5835
+ < p > The '< tt > llvm.sadd.with.overflow</ tt > ' family of intrinsic functions perform
5836
+ a signed addition of the two variables. They return a structure — the
5837
+ first element of which is the signed summation, and the second element of which
5838
+ is a bit specifying if the signed summation resulted in an overflow.</ p >
5839
+
5840
+ < h5 > Examples:</ h5 >
5841
+ < pre >
5842
+ %res = call {i32, i1} @llvm.sadd.with.overflow.i32(i32 %a, i32 %b)
5843
+ %sum = extractvalue {i32, i1} %res, 0
5844
+ %obit = extractvalue {i32, i1} %res, 1
5845
+ br i1 %obit, label %overflow, label %normal
5846
+ </ pre >
5847
+
5848
+ </ div >
5849
+
5850
+ <!-- _______________________________________________________________________ -->
5851
+ < div class ="doc_subsubsection ">
5852
+ < a name ="int_uadd_ovf "> '< tt > llvm.uadd.with.overflow.*</ tt > ' Intrinsics</ a >
5853
+ </ div >
5854
+
5855
+ < div class ="doc_text ">
5856
+
5857
+ < h5 > Syntax:</ h5 >
5858
+
5859
+ < p > This is an overloaded intrinsic. You can use < tt > llvm.uadd.with.overflow</ tt >
5860
+ on any integer bit width. However, not all targets support all bit widths.</ p >
5861
+
5862
+ < pre >
5863
+ declare {i16, i1} @llvm.uadd.with.overflow.i16(i16 %a, i16 %b)
5864
+ declare {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
5865
+ declare {i64, i1} @llvm.uadd.with.overflow.i64(i64 %a, i64 %b)
5866
+ </ pre >
5867
+
5868
+ < h5 > Overview:</ h5 >
5869
+
5870
+ < p > The '< tt > llvm.uadd.with.overflow</ tt > ' family of intrinsic functions perform
5871
+ an unsigned addition of the two arguments, and indicate whether a carry occurred
5872
+ during the unsigned summation.</ p >
5873
+
5874
+ < h5 > Arguments:</ h5 >
5875
+
5876
+ < p > The arguments (%a and %b) and the first element of the result structure may
5877
+ be of integer types of any bit width, but they must have the same bit width. The
5878
+ second element of the result structure must be of type < tt > i1</ tt > . < tt > %a</ tt >
5879
+ and < tt > %b</ tt > are the two values that will undergo unsigned addition.</ p >
5880
+
5881
+ < h5 > Semantics:</ h5 >
5882
+
5883
+ < p > The '< tt > llvm.uadd.with.overflow</ tt > ' family of intrinsic functions perform
5884
+ an unsigned addition of the two arguments. They return a structure — the
5885
+ first element of which is the sum, and the second element of which is a bit
5886
+ specifying if the unsigned summation resulted in a carry.</ p >
5887
+
5888
+ < h5 > Examples:</ h5 >
5889
+ < pre >
5890
+ %res = call {i32, i1} @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
5891
+ %sum = extractvalue {i32, i1} %res, 0
5892
+ %obit = extractvalue {i32, i1} %res, 1
5893
+ br i1 %obit, label %carry, label %normal
5894
+ </ pre >
5895
+
5896
+ </ div >
5897
+
5898
+ <!-- _______________________________________________________________________ -->
5899
+ < div class ="doc_subsubsection ">
5900
+ < a name ="int_ssub_ovf "> '< tt > llvm.ssub.with.overflow.*</ tt > ' Intrinsics</ a >
5901
+ </ div >
5902
+
5903
+ < div class ="doc_text ">
5904
+
5905
+ < h5 > Syntax:</ h5 >
5906
+
5907
+ < p > This is an overloaded intrinsic. You can use < tt > llvm.ssub.with.overflow</ tt >
5908
+ on any integer bit width. However, not all targets support all bit widths.</ p >
5909
+
5910
+ < pre >
5911
+ declare {i16, i1} @llvm.ssub.with.overflow.i16(i16 %a, i16 %b)
5912
+ declare {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
5913
+ declare {i64, i1} @llvm.ssub.with.overflow.i64(i64 %a, i64 %b)
5914
+ </ pre >
5915
+
5916
+ < h5 > Overview:</ h5 >
5917
+
5918
+ < p > The '< tt > llvm.ssub.with.overflow</ tt > ' family of intrinsic functions perform
5919
+ a signed subtraction of the two arguments, and indicate whether an overflow
5920
+ occurred during the signed subtraction.</ p >
5921
+
5922
+ < h5 > Arguments:</ h5 >
5923
+
5924
+ < p > The arguments (%a and %b) and the first element of the result structure may
5925
+ be of integer types of any bit width, but they must have the same bit width. The
5926
+ second element of the result structure must be of type < tt > i1</ tt > . < tt > %a</ tt >
5927
+ and < tt > %b</ tt > are the two values that will undergo signed subtraction.</ p >
5928
+
5929
+ < h5 > Semantics:</ h5 >
5930
+
5931
+ < p > The '< tt > llvm.ssub.with.overflow</ tt > ' family of intrinsic functions perform
5932
+ a signed subtraction of the two arguments. They return a structure — the
5933
+ first element of which is the subtraction, and the second element of which is a bit
5934
+ specifying if the signed subtraction resulted in an overflow.</ p >
5935
+
5936
+ < h5 > Examples:</ h5 >
5937
+ < pre >
5938
+ %res = call {i32, i1} @llvm.ssub.with.overflow.i32(i32 %a, i32 %b)
5939
+ %sum = extractvalue {i32, i1} %res, 0
5940
+ %obit = extractvalue {i32, i1} %res, 1
5941
+ br i1 %obit, label %overflow, label %normal
5942
+ </ pre >
5943
+
5944
+ </ div >
5945
+
5946
+ <!-- _______________________________________________________________________ -->
5947
+ < div class ="doc_subsubsection ">
5948
+ < a name ="int_usub_ovf "> '< tt > llvm.usub.with.overflow.*</ tt > ' Intrinsics</ a >
5949
+ </ div >
5950
+
5951
+ < div class ="doc_text ">
5952
+
5953
+ < h5 > Syntax:</ h5 >
5954
+
5955
+ < p > This is an overloaded intrinsic. You can use < tt > llvm.usub.with.overflow</ tt >
5956
+ on any integer bit width. However, not all targets support all bit widths.</ p >
5957
+
5958
+ < pre >
5959
+ declare {i16, i1} @llvm.usub.with.overflow.i16(i16 %a, i16 %b)
5960
+ declare {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
5961
+ declare {i64, i1} @llvm.usub.with.overflow.i64(i64 %a, i64 %b)
5962
+ </ pre >
5963
+
5964
+ < h5 > Overview:</ h5 >
5965
+
5966
+ < p > The '< tt > llvm.usub.with.overflow</ tt > ' family of intrinsic functions perform
5967
+ an unsigned subtraction of the two arguments, and indicate whether an overflow
5968
+ occurred during the unsigned subtraction.</ p >
5969
+
5970
+ < h5 > Arguments:</ h5 >
5971
+
5972
+ < p > The arguments (%a and %b) and the first element of the result structure may
5973
+ be of integer types of any bit width, but they must have the same bit width. The
5974
+ second element of the result structure must be of type < tt > i1</ tt > . < tt > %a</ tt >
5975
+ and < tt > %b</ tt > are the two values that will undergo unsigned subtraction.</ p >
5976
+
5977
+ < h5 > Semantics:</ h5 >
5978
+
5979
+ < p > The '< tt > llvm.usub.with.overflow</ tt > ' family of intrinsic functions perform
5980
+ an unsigned subtraction of the two arguments. They return a structure — the
5981
+ first element of which is the subtraction, and the second element of which is a bit
5982
+ specifying if the unsigned subtraction resulted in an overflow.</ p >
5983
+
5984
+ < h5 > Examples:</ h5 >
5985
+ < pre >
5986
+ %res = call {i32, i1} @llvm.usub.with.overflow.i32(i32 %a, i32 %b)
5987
+ %sum = extractvalue {i32, i1} %res, 0
5988
+ %obit = extractvalue {i32, i1} %res, 1
5989
+ br i1 %obit, label %overflow, label %normal
5990
+ </ pre >
5991
+
5992
+ </ div >
5993
+
5994
+ <!-- _______________________________________________________________________ -->
5995
+ < div class ="doc_subsubsection ">
5996
+ < a name ="int_smul_ovf "> '< tt > llvm.smul.with.overflow.*</ tt > ' Intrinsics</ a >
5997
+ </ div >
5998
+
5999
+ < div class ="doc_text ">
6000
+
6001
+ < h5 > Syntax:</ h5 >
6002
+
6003
+ < p > This is an overloaded intrinsic. You can use < tt > llvm.smul.with.overflow</ tt >
6004
+ on any integer bit width. However, not all targets support all bit widths.</ p >
6005
+
6006
+ < pre >
6007
+ declare {i16, i1} @llvm.smul.with.overflow.i16(i16 %a, i16 %b)
6008
+ declare {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
6009
+ declare {i64, i1} @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
6010
+ </ pre >
6011
+
6012
+ < h5 > Overview:</ h5 >
6013
+
6014
+ < p > The '< tt > llvm.smul.with.overflow</ tt > ' family of intrinsic functions perform
6015
+ a signed multiplication of the two arguments, and indicate whether an overflow
6016
+ occurred during the signed multiplication.</ p >
6017
+
6018
+ < h5 > Arguments:</ h5 >
6019
+
6020
+ < p > The arguments (%a and %b) and the first element of the result structure may
6021
+ be of integer types of any bit width, but they must have the same bit width. The
6022
+ second element of the result structure must be of type < tt > i1</ tt > . < tt > %a</ tt >
6023
+ and < tt > %b</ tt > are the two values that will undergo signed multiplication.</ p >
6024
+
6025
+ < h5 > Semantics:</ h5 >
6026
+
6027
+ < p > The '< tt > llvm.smul.with.overflow</ tt > ' family of intrinsic functions perform
6028
+ a signed multiplication of the two arguments. They return a structure —
6029
+ the first element of which is the multiplication, and the second element of
6030
+ which is a bit specifying if the signed multiplication resulted in an
6031
+ overflow.</ p >
6032
+
6033
+ < h5 > Examples:</ h5 >
6034
+ < pre >
6035
+ %res = call {i32, i1} @llvm.smul.with.overflow.i32(i32 %a, i32 %b)
6036
+ %sum = extractvalue {i32, i1} %res, 0
6037
+ %obit = extractvalue {i32, i1} %res, 1
6038
+ br i1 %obit, label %overflow, label %normal
6039
+ </ pre >
6040
+
5785
6041
</ div >
5786
6042
5787
6043
<!-- ======================================================================= -->
0 commit comments