Mikhail Glushenkov | 03c050f | 2009-03-03 10:04:57 +0000 | [diff] [blame] | 1 | //===- Hello.cpp - Example code from "Writing an LLVMC Plugin" ------------===// |
Mikhail Glushenkov | c82ce4a | 2008-09-22 20:49:34 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Mikhail Glushenkov | c8813da | 2008-12-07 16:43:17 +0000 | [diff] [blame] | 10 | // Test plugin for LLVMC. Shows how to write plugins without using TableGen. |
Mikhail Glushenkov | c82ce4a | 2008-09-22 20:49:34 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Mikhail Glushenkov | 4a1a77c | 2008-09-22 20:50:40 +0000 | [diff] [blame] | 14 | #include "llvm/CompilerDriver/CompilationGraph.h" |
| 15 | #include "llvm/CompilerDriver/Plugin.h" |
Dan Gohman | ac95cc7 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 16 | #include "llvm/Support/raw_ostream.h" |
Mikhail Glushenkov | c82ce4a | 2008-09-22 20:49:34 +0000 | [diff] [blame] | 17 | |
| 18 | namespace { |
| 19 | struct MyPlugin : public llvmc::BasePlugin { |
Mikhail Glushenkov | e0ace0c | 2009-11-19 17:29:25 +0000 | [diff] [blame] | 20 | |
| 21 | void PreprocessOptions() const |
| 22 | {} |
| 23 | |
Mikhail Glushenkov | c82ce4a | 2008-09-22 20:49:34 +0000 | [diff] [blame] | 24 | void PopulateLanguageMap(llvmc::LanguageMap&) const |
Dan Gohman | ac95cc7 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 25 | { outs() << "Hello!\n"; } |
Mikhail Glushenkov | c82ce4a | 2008-09-22 20:49:34 +0000 | [diff] [blame] | 26 | |
| 27 | void PopulateCompilationGraph(llvmc::CompilationGraph&) const |
| 28 | {} |
| 29 | }; |
| 30 | |
Mikhail Glushenkov | 14ef059 | 2008-09-22 20:51:19 +0000 | [diff] [blame] | 31 | static llvmc::RegisterPlugin<MyPlugin> RP("Hello", "Hello World plugin"); |
Mikhail Glushenkov | c82ce4a | 2008-09-22 20:49:34 +0000 | [diff] [blame] | 32 | |
| 33 | } |