File tree Expand file tree Collapse file tree
sources/LLVMSharp.Interop/Extensions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -176,6 +176,40 @@ public readonly uint InstructionCallConv
176176
177177 public readonly LLVMBasicBlockRef InstructionParent => ( IsAInstruction != null ) ? LLVM . GetInstructionParent ( this ) : default ;
178178
179+ public readonly IEnumerable < LLVMValueRef > Instructions
180+ {
181+ get
182+ {
183+ if ( IsAFunction != default )
184+ {
185+ return GetFunctionInstructions ( this ) ;
186+ }
187+ else if ( IsABasicBlock != default )
188+ {
189+ return AsBasicBlock ( ) . Instructions ;
190+ }
191+ else if ( IsAInstruction != default )
192+ {
193+ return [ this ] ;
194+ }
195+ else
196+ {
197+ return [ ] ;
198+ }
199+
200+ static IEnumerable < LLVMValueRef > GetFunctionInstructions ( LLVMValueRef function )
201+ {
202+ foreach ( LLVMBasicBlockRef basicBlock in function . GetBasicBlocks ( ) )
203+ {
204+ foreach ( LLVMValueRef instruction in basicBlock . Instructions )
205+ {
206+ yield return instruction ;
207+ }
208+ }
209+ }
210+ }
211+ }
212+
179213 public readonly uint IntrinsicID => ( Handle != IntPtr . Zero ) ? LLVM . GetIntrinsicID ( this ) : default ;
180214
181215 public readonly LLVMValueRef IsAAddrSpaceCastInst => LLVM . IsAAddrSpaceCastInst ( this ) ;
You can’t perform that action at this time.
0 commit comments