Commit Graph

891 Commits

Author SHA1 Message Date
David Neto
97fc6aa3b8 ForEachInst optionally runs on attached debug line insts
Also:
- Add const forms of ForEachInst
- Rewrite Module::ToBinary in terms of ForEachInst
- Add Instruction::ToBinaryWithoutAttachedDebugInsts
- Delete the ToBinary method on Function, BasicBlock, and Instruction
  since it can now be implemented with ForEachInst in a less confusing
  way, e.g. without recursion.
- Preserve debug line instructions on OpFunctionEnd (and store that
  instruction as a unique-pointer, for regularity).
2016-08-25 11:43:22 -04:00
Lei Zhang
f51d82338e Add a home brewed make_unique to ease creating unique_ptrs. 2016-08-24 09:41:55 -04:00
David Neto
ccabcc4673 Add opt::ir::Module::SetIdBound 2016-08-23 15:20:34 -04:00
qining
7e775aa99e Get the number of elements for Vector and Matrix type 2016-08-23 11:34:24 -04:00
qining
b891845b53 Refine the DefUseManager
* Fix the behavior when analyzing an individual instruction:
  * exisiting instruction:
      Clear the original records and re-analyze it as a new instruction.
  * new instruction with exisiting result id:
      Clear the original records of the exisiting result id. This means
      the records of the analyzed result-id-defining instruction will be
      overwritten by the record of the new instruction with the same
      result id.
  * new instruction with new result id or without result id:
      Just update the internal records to incorperate the new
      instruction.
* Add tests for analyzing individual instruction w/o an exisiting module.
* Refactor ClearInst() implementation
* Remove ClearDef() function.
* Fixed a bug in DefUseManager::ReplaceAllUsesWith() that OpName
  instruction may trigger the assertion incorrectly.
* update the blurbs for EraseUseRecordsOfOperandIds()
2016-08-17 23:13:01 -04:00
qining
6c5bdc9a39 Get the width from integer and float type 2016-08-17 20:33:56 -04:00
qining
e8b7c7b210 Replace the SetOperand() with SetInOperand() and SetResultType() 2016-08-16 15:05:07 -04:00
Lei Zhang
b65124f097 Make clear that we are using ptrdiff_t as the iterator difference type.
And ptrdiff_t is a implementation defined signed type. Comparing it
with unsigned number literal causes compiler warnings.
2016-08-16 11:21:08 -04:00
Lei Zhang
9747d33d08 Derive iterator from std::iterator to reap standarad algorithms.
By deriving from std::iterator, iterator_traits will be properly
set up for our custom iterator type, thus we can use algorithms
from STL with our custom iterators.
2016-08-15 16:29:56 -04:00
Lei Zhang
1eec0ed4b9 Make analyses RAII-like and turn disable copy/move constructors. 2016-08-15 13:41:47 -04:00
Lei Zhang
097ff25ea7 Allow OpUndef appearing in the type and global variable section.
Also clean up API functions for adding instructions into the
type and global values section.
2016-08-15 10:44:14 -04:00
qining
c814911904 Add another construtor for opt::ir::Instruction 2016-08-13 11:17:11 -04:00
qining
d065593404 Add iterator getter interface for types_values_ 2016-08-12 15:10:51 -04:00
Lei Zhang
94912ad1ba Turn off modifying methods for const iterators. 2016-08-12 14:05:41 -04:00
qining
81532584cb Clear old def-use record when re-analyze an ID 2016-08-12 13:04:07 -04:00
Lei Zhang
95dc16d1ec Add make_range() & make_const_range() for creating iterator ranges. 2016-08-12 10:34:47 -04:00
Lei Zhang
4b3247feba Avoid non-oneliner definition in class and add missing iterators. 2016-08-12 10:34:47 -04:00
qining
7a94e66433 Move the def-use analysis for single inst to public 2016-08-12 10:25:37 -04:00
qining
e5bb46d274 Add getter for pointee, element type 2016-08-11 20:53:57 -04:00
Lei Zhang
645ee1d9e0 Create an iterator class for in-memory representation. 2016-08-11 18:35:12 -04:00
qining
f949e321f2 Make the lookup up of type id accepts const arg 2016-08-11 18:21:57 -04:00
David Neto
82405cf499 Reuse the iterator on Id and type lookup 2016-08-11 18:18:12 -04:00
qining
f4e3a905d4 Add the const version of AsXXtype() interface. 2016-08-11 17:13:43 -04:00
qining
cd6d6c0ccf Add GetId(Type* type) API to the type manager 2016-08-11 15:10:09 -04:00
Lei Zhang
dda9de965d Make type manager RAII-like w.r.t. the module to be analyzed. 2016-08-10 12:53:17 -04:00
Lei Zhang
c562e231e3 Optimization: Add type manager.
Type manager will construct a map of types gradually from
instructions.
2016-08-10 12:53:17 -04:00
Lei Zhang
6d4d15b9d0 Optimization: Add type class hierarchy. 2016-08-10 12:53:17 -04:00
Lei Zhang
80c94a4fa8 Change the interfaces of in-memory representation to use pointers.
Previously we use vectors of objects and move semantics to handle
ownership. That approach has the flaw that inserting an object into
the middle of a vector, which may trigger a vector reallocation,
can invalidate some addresses taken from instructions.

Now the in-memory representation internally uses vector of unique
pointers to handle ownership. Since objects are explicitly heap-
allocated now, pointers to them won't be invalidated by vector
resizing anymore.
2016-08-10 12:11:33 -04:00
Lei Zhang
485f513a29 Manually create move the constructor/assignment for Instruction.
This is because some old visual studio versions (e.g., 2013) do
not support automatically generating move constructors/assignments.
2016-08-09 19:27:13 -04:00
qining
60461428f4 Separate pass.h from passes.h
Future pass implementations should only need to include pass.h
2016-08-09 17:16:52 -04:00
qining
51a2484b36 Dead constant elimination
A pass to remove dead constants, including both front-end constants and spec
constants.

This pass does not handle dead variables and types.
2016-08-08 17:17:15 -04:00
qining
5be1ee173f Add blurbs for freeze-spec-const pass 2016-08-05 10:39:50 -04:00
Lei Zhang
64ff3c6dc1 Optimization: Add def use analysis. 2016-07-29 15:45:14 -04:00
Lei Zhang
1db4cb456b Use default copy/move constructors/assignments for Instruction. 2016-07-29 00:58:09 -04:00
Lei Zhang
dcf28bf6ce Allow missing memory model instructions in modules. 2016-07-29 00:58:09 -04:00
qining
a24506266b Freeze spec constants to their default values
Add a pass to freeze spec constants to their default values. This pass does
not fold the frozen spec constants and does not handle SpecConstantOp
instructions and SpecConstantComposite instructions.
2016-07-28 15:23:30 -04:00
qining
d503d75cc3 Use friendly disassembly output 2016-07-28 09:39:42 -04:00
Lei Zhang
2c4c73cf37 Add Pass, PassManager, and StripDebugInfoPass. 2016-06-29 17:32:00 -04:00
Lei Zhang
abf8f6413c Promote ir namespace and create draft libspirv.{h|c}pp. 2016-06-28 14:52:34 -04:00
Lei Zhang
8590f9cc81 Add IrBuilder for constructing SPIR-V in-memory representation. 2016-06-27 16:57:42 -04:00
Lei Zhang
3df8f7cebd Add classes for representing SPIR-V language constructs in memory. 2016-06-24 20:54:06 -04:00