From 9a5dc4f7e5821a211eb0c7d04c0afcb8c7d58ee0 Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Thu, 27 May 2004 00:57:51 +0000 Subject: [PATCH] Add section on the newly added Instruction and subclasses constructor variant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13802 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ProgrammersManual.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index 5cfd0ea56c7..8c678a30c06 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -808,7 +808,22 @@ into an existing sequence of instructions that form a BasicBlock:

BasicBlock, and a newly-created instruction we wish to insert before *pi, we do the following:

-
  BasicBlock *pb = ...;
Instruction *pi = ...;
Instruction *newInst = new Instruction(...);
pb->getInstList().insert(pi, newInst); // inserts newInst before pi in pb
+
  BasicBlock *pb = ...;
Instruction *pi = ...;
Instruction *newInst = new Instruction(...);
pb->getInstList().insert(pi, newInst); // inserts newInst before pi in pb
+ +

Appending to the end of a BasicBlock is so common that + the Instruction class and Instruction-derived + classes provide constructors which take a pointer to a + BasicBlock to be appended to. For example code that + looked like:

+ +
  BasicBlock *pb = ...;
Instruction *newInst = new Instruction(...);
pb->getInstList().push_back(newInst); // appends newInst to pb
+ +

becomes:

+ +
  BasicBlock *pb = ...;
Instruction *newInst = new Instruction(..., pb);
+ +

which is much cleaner, especially if you are creating + long instruction streams.

  • Insertion into an implicit instruction list -- 2.34.1