---
# System prepended metadata

title: Extending LLVM

---

# Extending LLVM

* before extending LLVM, go [LLVM forums](https://discourse.llvm.org/) to check whether the targeted things already existed
* adding a new intrinsic function to LLVM is much easier than adding a new instruction
* adding a new SelectionDAG node to LLVM is much easier than adding a new instruction

### Adding a new intrinsic function
1. Document the intrinsic. [link](https://llvm.org/docs/LangRef.html)
2. Add an entry for your intrinsic. [link](https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/Intrinsics.td)
3. (optional) Add support to it in the *canConstantFoldCallTo* and *ConstantFoldCall* functions. [link](https://llvm.org/doxygen/ConstantFolding_8cpp_source.html)
4. Add test cases for your test cases to the test suite. [link](https://github.com/llvm/llvm-test-suite), [guide](https://llvm.org/docs/TestSuiteGuide.html)

### Adding a new SelectionDAG node
1. Add an enum value for the new SelectionDAG node. [link](https://llvm.org/doxygen/ISDOpcodes_8h_source.html)