blob: a7179eae8bd16fb161cc8b8d7660200559d4dffc [file] [log] [blame]
Mikhail Glushenkov03c050f2009-03-03 10:04:57 +00001//===- Hello.cpp - Example code from "Writing an LLVMC Plugin" ------------===//
Mikhail Glushenkovc82ce4a2008-09-22 20:49:34 +00002//
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 Glushenkovc8813da2008-12-07 16:43:17 +000010// Test plugin for LLVMC. Shows how to write plugins without using TableGen.
Mikhail Glushenkovc82ce4a2008-09-22 20:49:34 +000011//
12//===----------------------------------------------------------------------===//
13
Mikhail Glushenkov4a1a77c2008-09-22 20:50:40 +000014#include "llvm/CompilerDriver/CompilationGraph.h"
15#include "llvm/CompilerDriver/Plugin.h"
Dan Gohmanac95cc72009-07-16 15:30:09 +000016#include "llvm/Support/raw_ostream.h"
Mikhail Glushenkovc82ce4a2008-09-22 20:49:34 +000017
18namespace {
19struct MyPlugin : public llvmc::BasePlugin {
Mikhail Glushenkove0ace0c2009-11-19 17:29:25 +000020
21 void PreprocessOptions() const
22 {}
23
Mikhail Glushenkovc82ce4a2008-09-22 20:49:34 +000024 void PopulateLanguageMap(llvmc::LanguageMap&) const
Dan Gohmanac95cc72009-07-16 15:30:09 +000025 { outs() << "Hello!\n"; }
Mikhail Glushenkovc82ce4a2008-09-22 20:49:34 +000026
27 void PopulateCompilationGraph(llvmc::CompilationGraph&) const
28 {}
29};
30
Mikhail Glushenkov14ef0592008-09-22 20:51:19 +000031static llvmc::RegisterPlugin<MyPlugin> RP("Hello", "Hello World plugin");
Mikhail Glushenkovc82ce4a2008-09-22 20:49:34 +000032
33}