@@ -898,6 +898,128 @@ impl NumBuilderMethods<'tcx> for Builder<'a, 'll, 'tcx> {
898
898
}
899
899
}
900
900
901
+ impl UnwindBuilderMethods < ' tcx > for Builder < ' a , ' ll , ' tcx > {
902
+ fn invoke (
903
+ & mut self ,
904
+ llfn : & ' ll Value ,
905
+ args : & [ & ' ll Value ] ,
906
+ then : & ' ll BasicBlock ,
907
+ catch : & ' ll BasicBlock ,
908
+ funclet : Option < & Funclet < ' ll > > ,
909
+ ) -> & ' ll Value {
910
+ self . count_insn ( "invoke" ) ;
911
+
912
+ debug ! ( "Invoke {:?} with args ({:?})" ,
913
+ llfn,
914
+ args) ;
915
+
916
+ let args = self . check_call ( "invoke" , llfn, args) ;
917
+ let bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
918
+ let bundle = bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
919
+
920
+ unsafe {
921
+ llvm:: LLVMRustBuildInvoke ( self . llbuilder ,
922
+ llfn,
923
+ args. as_ptr ( ) ,
924
+ args. len ( ) as c_uint ,
925
+ then,
926
+ catch,
927
+ bundle,
928
+ noname ( ) )
929
+ }
930
+ }
931
+
932
+ fn landing_pad ( & mut self , ty : & ' ll Type , pers_fn : & ' ll Value ,
933
+ num_clauses : usize ) -> & ' ll Value {
934
+ self . count_insn ( "landingpad" ) ;
935
+ unsafe {
936
+ llvm:: LLVMBuildLandingPad ( self . llbuilder , ty, pers_fn,
937
+ num_clauses as c_uint , noname ( ) )
938
+ }
939
+ }
940
+
941
+ fn set_cleanup ( & mut self , landing_pad : & ' ll Value ) {
942
+ self . count_insn ( "setcleanup" ) ;
943
+ unsafe {
944
+ llvm:: LLVMSetCleanup ( landing_pad, llvm:: True ) ;
945
+ }
946
+ }
947
+
948
+ fn resume ( & mut self , exn : & ' ll Value ) -> & ' ll Value {
949
+ self . count_insn ( "resume" ) ;
950
+ unsafe {
951
+ llvm:: LLVMBuildResume ( self . llbuilder , exn)
952
+ }
953
+ }
954
+
955
+ fn cleanup_pad ( & mut self ,
956
+ parent : Option < & ' ll Value > ,
957
+ args : & [ & ' ll Value ] ) -> Funclet < ' ll > {
958
+ self . count_insn ( "cleanuppad" ) ;
959
+ let name = const_cstr ! ( "cleanuppad" ) ;
960
+ let ret = unsafe {
961
+ llvm:: LLVMRustBuildCleanupPad ( self . llbuilder ,
962
+ parent,
963
+ args. len ( ) as c_uint ,
964
+ args. as_ptr ( ) ,
965
+ name. as_ptr ( ) )
966
+ } ;
967
+ Funclet :: new ( ret. expect ( "LLVM does not have support for cleanuppad" ) )
968
+ }
969
+
970
+ fn cleanup_ret (
971
+ & mut self , funclet : & Funclet < ' ll > ,
972
+ unwind : Option < & ' ll BasicBlock > ,
973
+ ) -> & ' ll Value {
974
+ self . count_insn ( "cleanupret" ) ;
975
+ let ret = unsafe {
976
+ llvm:: LLVMRustBuildCleanupRet ( self . llbuilder , funclet. cleanuppad ( ) , unwind)
977
+ } ;
978
+ ret. expect ( "LLVM does not have support for cleanupret" )
979
+ }
980
+
981
+ fn catch_pad ( & mut self ,
982
+ parent : & ' ll Value ,
983
+ args : & [ & ' ll Value ] ) -> Funclet < ' ll > {
984
+ self . count_insn ( "catchpad" ) ;
985
+ let name = const_cstr ! ( "catchpad" ) ;
986
+ let ret = unsafe {
987
+ llvm:: LLVMRustBuildCatchPad ( self . llbuilder , parent,
988
+ args. len ( ) as c_uint , args. as_ptr ( ) ,
989
+ name. as_ptr ( ) )
990
+ } ;
991
+ Funclet :: new ( ret. expect ( "LLVM does not have support for catchpad" ) )
992
+ }
993
+
994
+ fn catch_switch (
995
+ & mut self ,
996
+ parent : Option < & ' ll Value > ,
997
+ unwind : Option < & ' ll BasicBlock > ,
998
+ num_handlers : usize ,
999
+ ) -> & ' ll Value {
1000
+ self . count_insn ( "catchswitch" ) ;
1001
+ let name = const_cstr ! ( "catchswitch" ) ;
1002
+ let ret = unsafe {
1003
+ llvm:: LLVMRustBuildCatchSwitch ( self . llbuilder , parent, unwind,
1004
+ num_handlers as c_uint ,
1005
+ name. as_ptr ( ) )
1006
+ } ;
1007
+ ret. expect ( "LLVM does not have support for catchswitch" )
1008
+ }
1009
+
1010
+ fn add_handler ( & mut self , catch_switch : & ' ll Value , handler : & ' ll BasicBlock ) {
1011
+ unsafe {
1012
+ llvm:: LLVMRustAddHandler ( catch_switch, handler) ;
1013
+ }
1014
+ }
1015
+
1016
+ fn set_personality_fn ( & mut self , personality : & ' ll Value ) {
1017
+ unsafe {
1018
+ llvm:: LLVMSetPersonalityFn ( self . llfn ( ) , personality) ;
1019
+ }
1020
+ }
1021
+ }
1022
+
901
1023
impl BuilderMethods < ' a , ' tcx > for Builder < ' a , ' ll , ' tcx > {
902
1024
fn new_block < ' b > (
903
1025
cx : & ' a CodegenCx < ' ll , ' tcx > ,
@@ -988,36 +1110,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
988
1110
}
989
1111
}
990
1112
991
- fn invoke (
992
- & mut self ,
993
- llfn : & ' ll Value ,
994
- args : & [ & ' ll Value ] ,
995
- then : & ' ll BasicBlock ,
996
- catch : & ' ll BasicBlock ,
997
- funclet : Option < & Funclet < ' ll > > ,
998
- ) -> & ' ll Value {
999
- self . count_insn ( "invoke" ) ;
1000
-
1001
- debug ! ( "Invoke {:?} with args ({:?})" ,
1002
- llfn,
1003
- args) ;
1004
-
1005
- let args = self . check_call ( "invoke" , llfn, args) ;
1006
- let bundle = funclet. map ( |funclet| funclet. bundle ( ) ) ;
1007
- let bundle = bundle. as_ref ( ) . map ( |b| & * b. raw ) ;
1008
-
1009
- unsafe {
1010
- llvm:: LLVMRustBuildInvoke ( self . llbuilder ,
1011
- llfn,
1012
- args. as_ptr ( ) ,
1013
- args. len ( ) as c_uint ,
1014
- then,
1015
- catch,
1016
- bundle,
1017
- noname ( ) )
1018
- }
1019
- }
1020
-
1021
1113
fn unreachable ( & mut self ) {
1022
1114
self . count_insn ( "unreachable" ) ;
1023
1115
unsafe {
@@ -1119,96 +1211,6 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
1119
1211
}
1120
1212
}
1121
1213
1122
- fn landing_pad ( & mut self , ty : & ' ll Type , pers_fn : & ' ll Value ,
1123
- num_clauses : usize ) -> & ' ll Value {
1124
- self . count_insn ( "landingpad" ) ;
1125
- unsafe {
1126
- llvm:: LLVMBuildLandingPad ( self . llbuilder , ty, pers_fn,
1127
- num_clauses as c_uint , noname ( ) )
1128
- }
1129
- }
1130
-
1131
- fn set_cleanup ( & mut self , landing_pad : & ' ll Value ) {
1132
- self . count_insn ( "setcleanup" ) ;
1133
- unsafe {
1134
- llvm:: LLVMSetCleanup ( landing_pad, llvm:: True ) ;
1135
- }
1136
- }
1137
-
1138
- fn resume ( & mut self , exn : & ' ll Value ) -> & ' ll Value {
1139
- self . count_insn ( "resume" ) ;
1140
- unsafe {
1141
- llvm:: LLVMBuildResume ( self . llbuilder , exn)
1142
- }
1143
- }
1144
-
1145
- fn cleanup_pad ( & mut self ,
1146
- parent : Option < & ' ll Value > ,
1147
- args : & [ & ' ll Value ] ) -> Funclet < ' ll > {
1148
- self . count_insn ( "cleanuppad" ) ;
1149
- let name = const_cstr ! ( "cleanuppad" ) ;
1150
- let ret = unsafe {
1151
- llvm:: LLVMRustBuildCleanupPad ( self . llbuilder ,
1152
- parent,
1153
- args. len ( ) as c_uint ,
1154
- args. as_ptr ( ) ,
1155
- name. as_ptr ( ) )
1156
- } ;
1157
- Funclet :: new ( ret. expect ( "LLVM does not have support for cleanuppad" ) )
1158
- }
1159
-
1160
- fn cleanup_ret (
1161
- & mut self , funclet : & Funclet < ' ll > ,
1162
- unwind : Option < & ' ll BasicBlock > ,
1163
- ) -> & ' ll Value {
1164
- self . count_insn ( "cleanupret" ) ;
1165
- let ret = unsafe {
1166
- llvm:: LLVMRustBuildCleanupRet ( self . llbuilder , funclet. cleanuppad ( ) , unwind)
1167
- } ;
1168
- ret. expect ( "LLVM does not have support for cleanupret" )
1169
- }
1170
-
1171
- fn catch_pad ( & mut self ,
1172
- parent : & ' ll Value ,
1173
- args : & [ & ' ll Value ] ) -> Funclet < ' ll > {
1174
- self . count_insn ( "catchpad" ) ;
1175
- let name = const_cstr ! ( "catchpad" ) ;
1176
- let ret = unsafe {
1177
- llvm:: LLVMRustBuildCatchPad ( self . llbuilder , parent,
1178
- args. len ( ) as c_uint , args. as_ptr ( ) ,
1179
- name. as_ptr ( ) )
1180
- } ;
1181
- Funclet :: new ( ret. expect ( "LLVM does not have support for catchpad" ) )
1182
- }
1183
-
1184
- fn catch_switch (
1185
- & mut self ,
1186
- parent : Option < & ' ll Value > ,
1187
- unwind : Option < & ' ll BasicBlock > ,
1188
- num_handlers : usize ,
1189
- ) -> & ' ll Value {
1190
- self . count_insn ( "catchswitch" ) ;
1191
- let name = const_cstr ! ( "catchswitch" ) ;
1192
- let ret = unsafe {
1193
- llvm:: LLVMRustBuildCatchSwitch ( self . llbuilder , parent, unwind,
1194
- num_handlers as c_uint ,
1195
- name. as_ptr ( ) )
1196
- } ;
1197
- ret. expect ( "LLVM does not have support for catchswitch" )
1198
- }
1199
-
1200
- fn add_handler ( & mut self , catch_switch : & ' ll Value , handler : & ' ll BasicBlock ) {
1201
- unsafe {
1202
- llvm:: LLVMRustAddHandler ( catch_switch, handler) ;
1203
- }
1204
- }
1205
-
1206
- fn set_personality_fn ( & mut self , personality : & ' ll Value ) {
1207
- unsafe {
1208
- llvm:: LLVMSetPersonalityFn ( self . llfn ( ) , personality) ;
1209
- }
1210
- }
1211
-
1212
1214
fn add_case ( & mut self , s : & ' ll Value , on_val : & ' ll Value , dest : & ' ll BasicBlock ) {
1213
1215
unsafe {
1214
1216
llvm:: LLVMAddCase ( s, on_val, dest)
0 commit comments