# dmd.e2ir

Converts expressions to Intermediate Representation (IR) for the backend.

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: e2ir.d

Documentation: https://dlang.org/phobos/dmd_e2ir.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/e2ir.d

- `elAssign`

  #### Declaration

  `elem* `elAssign`(elem* `e1`, elem* `e2`, Type `t`, type* `tx`);`

  Generate a copy from `e2` to `e1`.

  #### Parameters

  `elem* `e1`` | lvalue
  `elem* `e2`` | rvalue
  `Type `t`` | value type
  `type* `tx`` | if !`null`, then `t` converted to C type

  #### Return Value

  generated elem

- `type_zeroCopy`

  #### Declaration

  `bool `type_zeroCopy`(type* `t`);`

  Determine if zero bits need to be copied for this backend type

  #### Parameters

  `type* `t`` | backend type

  #### Return Value

  `true` if 0 bits

- `toStringSymbol`

  #### Declaration

  `Symbol* `toStringSymbol`(const(char)* `str`, size_t `len`, size_t `sz`);`

  Write read-only string to object file, create a local symbol for it. Makes a copy of `str`'s contents, does not keep a reference to it.

  #### Parameters

  `const(char)* `str`` | string
  `size_t `len`` | number of code units in string
  `size_t `sz`` | number of bytes per code unit

  #### Return Value

  Symbol

- `toStringSymbol`

  #### Declaration

  `Symbol* `toStringSymbol`(StringExp `se`);`

  Turn StringExp into Symbol.

- `toTraceGC`

  #### Declaration

  `void `toTraceGC`(ref IRState `irs`, elem* `e`, const ref Loc `loc`);`

  Replace call to GC allocator with call to tracing GC allocator.

  #### Parameters

  `IRState `irs`` | to get function from
  `elem* `e`` | elem to modify in place
  `Loc `loc`` | to get file/line from

- `toElemDtor`

  #### Declaration

  `elem* `toElemDtor`(Expression `e`, ref IRState `irs`);`

  Convert Expression to elem, then append destructors for any temporaries created in elem.

  #### Parameters

  `Expression `e`` | Expression to convert
  `IRState `irs`` | context

  #### Return Value

  generated elem tree

- `addressElem`

  #### Declaration

  `elem* `addressElem`(elem* `e`, Type `t`, bool `alwaysCopy` = false);`

  Take address of an elem. Accounts for `e` being an rvalue by assigning the rvalue to a temp.

  #### Parameters

  `elem* `e`` | elem to take address of
  `Type `t`` | Type of elem
  `bool `alwaysCopy`` | when `true`, always copy `e` to a tmp

  #### Return Value

  the equivalent of &`e`

- `clearStringTab`

  #### Declaration

  `void `clearStringTab`();`

  Reset stringTab[] between object files being emitted, because the symbols are local.

- `toElem`

  #### Declaration

  `elem* `toElem`(Expression `e`, ref IRState `irs`);`

  Convert Expression to backend elem.

  #### Parameters

  `Expression `e`` | expression tree
  `IRState `irs`` | context

  #### Return Value

  backend elem tree