@@ -58,17 +58,9 @@ class UnaryInstruction : public Instruction {
58
58
constexpr static IntrusiveOperandsAllocMarker AllocMarker{1 };
59
59
60
60
protected:
61
- UnaryInstruction (Type *Ty, unsigned iType, Value *V, BasicBlock::iterator IB)
62
- : Instruction(Ty, iType, AllocMarker, IB) {
63
- Op<0 >() = V;
64
- }
65
61
UnaryInstruction (Type *Ty, unsigned iType, Value *V,
66
- Instruction *IB = nullptr )
67
- : Instruction(Ty, iType, AllocMarker, IB) {
68
- Op<0 >() = V;
69
- }
70
- UnaryInstruction (Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
71
- : Instruction(Ty, iType, AllocMarker, IAE) {
62
+ InsertPosition InsertBefore = nullptr )
63
+ : Instruction(Ty, iType, AllocMarker, InsertBefore) {
72
64
Op<0 >() = V;
73
65
}
74
66
@@ -130,27 +122,15 @@ class UnaryOperator : public UnaryInstruction {
130
122
// / These methods just forward to Create, and are useful when you
131
123
// / statically know what type of instruction you're going to create. These
132
124
// / helpers just save some typing.
133
- #define HANDLE_UNARY_INST (N, OPC, CLASS ) \
134
- static UnaryOperator *Create##OPC(Value *V, const Twine &Name = " " ) {\
135
- return Create (Instruction::OPC, V, Name);\
136
- }
137
- #include " llvm/IR/Instruction.def"
138
- #define HANDLE_UNARY_INST (N, OPC, CLASS ) \
139
- static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
140
- BasicBlock *BB) {\
141
- return Create (Instruction::OPC, V, Name, BB);\
142
- }
143
- #include " llvm/IR/Instruction.def"
144
- #define HANDLE_UNARY_INST (N, OPC, CLASS ) \
145
- static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
146
- Instruction *I) {\
147
- return Create (Instruction::OPC, V, Name, I);\
125
+ #define HANDLE_UNARY_INST (N, OPC, CLASS ) \
126
+ static UnaryOperator *Create##OPC(Value *V, const Twine &Name = " " ) { \
127
+ return Create (Instruction::OPC, V, Name); \
148
128
}
149
129
#include " llvm/IR/Instruction.def"
150
- #define HANDLE_UNARY_INST (N, OPC, CLASS ) \
151
- static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
152
- BasicBlock::iterator It ) {\
153
- return Create (Instruction::OPC, V, Name, It); \
130
+ #define HANDLE_UNARY_INST (N, OPC, CLASS ) \
131
+ static UnaryOperator *Create##OPC(Value *V, const Twine &Name, \
132
+ InsertPosition InsertBefore = nullptr ) { \
133
+ return Create (Instruction::OPC, V, Name, InsertBefore); \
154
134
}
155
135
#include " llvm/IR/Instruction.def"
156
136
@@ -221,28 +201,16 @@ class BinaryOperator : public Instruction {
221
201
// / These methods just forward to Create, and are useful when you
222
202
// / statically know what type of instruction you're going to create. These
223
203
// / helpers just save some typing.
224
- #define HANDLE_BINARY_INST (N, OPC, CLASS ) \
225
- static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
226
- const Twine &Name = " " ) {\
227
- return Create (Instruction::OPC, V1, V2, Name);\
204
+ #define HANDLE_BINARY_INST (N, OPC, CLASS ) \
205
+ static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
206
+ const Twine &Name = " " ) { \
207
+ return Create (Instruction::OPC, V1, V2, Name); \
228
208
}
229
209
#include " llvm/IR/Instruction.def"
230
- #define HANDLE_BINARY_INST (N, OPC, CLASS ) \
231
- static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
232
- const Twine &Name, BasicBlock *BB) {\
233
- return Create (Instruction::OPC, V1, V2, Name, BB);\
234
- }
235
- #include " llvm/IR/Instruction.def"
236
- #define HANDLE_BINARY_INST (N, OPC, CLASS ) \
237
- static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
238
- const Twine &Name, Instruction *I) {\
239
- return Create (Instruction::OPC, V1, V2, Name, I);\
240
- }
241
- #include " llvm/IR/Instruction.def"
242
- #define HANDLE_BINARY_INST (N, OPC, CLASS ) \
243
- static BinaryOperator *Create##OPC(Value *V1, Value *V2, \
244
- const Twine &Name, BasicBlock::iterator It) {\
245
- return Create (Instruction::OPC, V1, V2, Name, It);\
210
+ #define HANDLE_BINARY_INST (N, OPC, CLASS ) \
211
+ static BinaryOperator *Create##OPC(Value *V1, Value *V2, const Twine &Name, \
212
+ InsertPosition InsertBefore) { \
213
+ return Create (Instruction::OPC, V1, V2, Name, InsertBefore); \
246
214
}
247
215
#include " llvm/IR/Instruction.def"
248
216
@@ -313,21 +281,11 @@ class BinaryOperator : public Instruction {
313
281
BO->setHasNoSignedWrap (true );
314
282
return BO;
315
283
}
284
+
316
285
static BinaryOperator *CreateNSW (BinaryOps Opc, Value *V1, Value *V2,
317
- const Twine &Name, BasicBlock *BB) {
318
- BinaryOperator *BO = Create (Opc, V1, V2, Name, BB);
319
- BO->setHasNoSignedWrap (true );
320
- return BO;
321
- }
322
- static BinaryOperator *CreateNSW (BinaryOps Opc, Value *V1, Value *V2,
323
- const Twine &Name, Instruction *I) {
324
- BinaryOperator *BO = Create (Opc, V1, V2, Name, I);
325
- BO->setHasNoSignedWrap (true );
326
- return BO;
327
- }
328
- static BinaryOperator *CreateNSW (BinaryOps Opc, Value *V1, Value *V2,
329
- const Twine &Name, BasicBlock::iterator It) {
330
- BinaryOperator *BO = Create (Opc, V1, V2, Name, It);
286
+ const Twine &Name,
287
+ InsertPosition InsertBefore) {
288
+ BinaryOperator *BO = Create (Opc, V1, V2, Name, InsertBefore);
331
289
BO->setHasNoSignedWrap (true );
332
290
return BO;
333
291
}
@@ -338,21 +296,11 @@ class BinaryOperator : public Instruction {
338
296
BO->setHasNoUnsignedWrap (true );
339
297
return BO;
340
298
}
299
+
341
300
static BinaryOperator *CreateNUW (BinaryOps Opc, Value *V1, Value *V2,
342
- const Twine &Name, BasicBlock *BB) {
343
- BinaryOperator *BO = Create (Opc, V1, V2, Name, BB);
344
- BO->setHasNoUnsignedWrap (true );
345
- return BO;
346
- }
347
- static BinaryOperator *CreateNUW (BinaryOps Opc, Value *V1, Value *V2,
348
- const Twine &Name, Instruction *I) {
349
- BinaryOperator *BO = Create (Opc, V1, V2, Name, I);
350
- BO->setHasNoUnsignedWrap (true );
351
- return BO;
352
- }
353
- static BinaryOperator *CreateNUW (BinaryOps Opc, Value *V1, Value *V2,
354
- const Twine &Name, BasicBlock::iterator It) {
355
- BinaryOperator *BO = Create (Opc, V1, V2, Name, It);
301
+ const Twine &Name,
302
+ InsertPosition InsertBefore) {
303
+ BinaryOperator *BO = Create (Opc, V1, V2, Name, InsertBefore);
356
304
BO->setHasNoUnsignedWrap (true );
357
305
return BO;
358
306
}
@@ -363,22 +311,11 @@ class BinaryOperator : public Instruction {
363
311
BO->setIsExact (true );
364
312
return BO;
365
313
}
366
- static BinaryOperator *CreateExact (BinaryOps Opc, Value *V1, Value *V2,
367
- const Twine &Name, BasicBlock *BB) {
368
- BinaryOperator *BO = Create (Opc, V1, V2, Name, BB);
369
- BO->setIsExact (true );
370
- return BO;
371
- }
372
- static BinaryOperator *CreateExact (BinaryOps Opc, Value *V1, Value *V2,
373
- const Twine &Name, Instruction *I) {
374
- BinaryOperator *BO = Create (Opc, V1, V2, Name, I);
375
- BO->setIsExact (true );
376
- return BO;
377
- }
314
+
378
315
static BinaryOperator *CreateExact (BinaryOps Opc, Value *V1, Value *V2,
379
316
const Twine &Name,
380
- BasicBlock::iterator It ) {
381
- BinaryOperator *BO = Create (Opc, V1, V2, Name, It );
317
+ InsertPosition InsertBefore ) {
318
+ BinaryOperator *BO = Create (Opc, V1, V2, Name, InsertBefore );
382
319
BO->setIsExact (true );
383
320
return BO;
384
321
}
@@ -387,30 +324,17 @@ class BinaryOperator : public Instruction {
387
324
CreateDisjoint (BinaryOps Opc, Value *V1, Value *V2, const Twine &Name = " " );
388
325
static inline BinaryOperator *CreateDisjoint (BinaryOps Opc, Value *V1,
389
326
Value *V2, const Twine &Name,
390
- BasicBlock *BB);
391
- static inline BinaryOperator *CreateDisjoint (BinaryOps Opc, Value *V1,
392
- Value *V2, const Twine &Name,
393
- Instruction *I);
394
- static inline BinaryOperator *CreateDisjoint (BinaryOps Opc, Value *V1,
395
- Value *V2, const Twine &Name,
396
- BasicBlock::iterator It);
327
+ InsertPosition InsertBefore);
397
328
398
329
#define DEFINE_HELPERS (OPC, NUWNSWEXACT ) \
399
330
static BinaryOperator *Create##NUWNSWEXACT##OPC(Value *V1, Value *V2, \
400
331
const Twine &Name = " " ) { \
401
332
return Create##NUWNSWEXACT (Instruction::OPC, V1, V2, Name); \
402
333
} \
403
334
static BinaryOperator *Create##NUWNSWEXACT##OPC( \
404
- Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { \
405
- return Create##NUWNSWEXACT (Instruction::OPC, V1, V2, Name, BB); \
406
- } \
407
- static BinaryOperator *Create##NUWNSWEXACT##OPC( \
408
- Value *V1, Value *V2, const Twine &Name, Instruction *I) { \
409
- return Create##NUWNSWEXACT (Instruction::OPC, V1, V2, Name, I); \
410
- } \
411
- static BinaryOperator *Create##NUWNSWEXACT##OPC( \
412
- Value *V1, Value *V2, const Twine &Name, BasicBlock::iterator It) { \
413
- return Create##NUWNSWEXACT (Instruction::OPC, V1, V2, Name, It); \
335
+ Value *V1, Value *V2, const Twine &Name, \
336
+ InsertPosition InsertBefore = nullptr ) { \
337
+ return Create##NUWNSWEXACT (Instruction::OPC, V1, V2, Name, InsertBefore); \
414
338
}
415
339
416
340
DEFINE_HELPERS (Add, NSW) // CreateNSWAdd
@@ -501,22 +425,8 @@ BinaryOperator *BinaryOperator::CreateDisjoint(BinaryOps Opc, Value *V1,
501
425
}
502
426
BinaryOperator *BinaryOperator::CreateDisjoint (BinaryOps Opc, Value *V1,
503
427
Value *V2, const Twine &Name,
504
- BasicBlock *BB) {
505
- BinaryOperator *BO = Create (Opc, V1, V2, Name, BB);
506
- cast<PossiblyDisjointInst>(BO)->setIsDisjoint (true );
507
- return BO;
508
- }
509
- BinaryOperator *BinaryOperator::CreateDisjoint (BinaryOps Opc, Value *V1,
510
- Value *V2, const Twine &Name,
511
- Instruction *I) {
512
- BinaryOperator *BO = Create (Opc, V1, V2, Name, I);
513
- cast<PossiblyDisjointInst>(BO)->setIsDisjoint (true );
514
- return BO;
515
- }
516
- BinaryOperator *BinaryOperator::CreateDisjoint (BinaryOps Opc, Value *V1,
517
- Value *V2, const Twine &Name,
518
- BasicBlock::iterator It) {
519
- BinaryOperator *BO = Create (Opc, V1, V2, Name, It);
428
+ InsertPosition InsertBefore) {
429
+ BinaryOperator *BO = Create (Opc, V1, V2, Name, InsertBefore);
520
430
cast<PossiblyDisjointInst>(BO)->setIsDisjoint (true );
521
431
return BO;
522
432
}
0 commit comments