OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.dg/] [plugin/] [start_unit_plugin.c] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* This plugin tests the correct operation of a PLUGIN_START_UNIT callback.
2
 * By the time a PLUGIN_START_UNIT callback is invoked, the frontend
3
 * initialization should have completed. At least the different *_type_nodes
4
 * should have been created. This plugin creates an artifical global
5
 * interger variable.
6
 *
7
*/
8
#include "gcc-plugin.h"
9
#include "config.h"
10
#include "system.h"
11
#include "coretypes.h"
12
#include "tm.h"
13
#include "toplev.h"
14
#include "basic-block.h"
15
#include "gimple.h"
16
#include "tree.h"
17
#include "tree-pass.h"
18
#include "intl.h"
19
 
20
int plugin_is_GPL_compatible;
21
static tree fake_var = NULL;
22
 
23
static bool
24
gate_start_unit (void)
25
{
26
  return true;
27
}
28
 
29
static void start_unit_callback (void *gcc_data, void *user_data)
30
{
31
  if (integer_type_node) {
32
    fake_var = build_decl (UNKNOWN_LOCATION, VAR_DECL,
33
                           get_identifier ("_fake_var_"),
34
                           integer_type_node);
35
    TREE_PUBLIC (fake_var) = 1;
36
    DECL_ARTIFICIAL (fake_var) = 1;
37
  }
38
}
39
 
40
static void finish_unit_callback (void *gcc_data, void *user_data)
41
{
42
  if (fake_var == NULL) {
43
    printf ("fake_var not created \n");
44
    return;
45
  }
46
  if (TREE_CODE (fake_var) != VAR_DECL) {
47
    printf ("fake_var not a VAR_DECL \n");
48
    return;
49
  }
50
  if (TREE_CODE (TREE_TYPE (fake_var)) != INTEGER_TYPE) {
51
    printf ("fake_var not INTEGER_TYPE \n");
52
    return;
53
  }
54
  if (DECL_ARTIFICIAL (fake_var) == 0) {
55
    printf ("fake_var not ARTIFICIAL \n");
56
    return;
57
  }
58
}
59
 
60
int plugin_init (struct plugin_name_args *plugin_info,
61
                 struct plugin_gcc_version *version)
62
{
63
  register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
64
  register_callback ("finish_unit", PLUGIN_FINISH_UNIT, &finish_unit_callback, NULL);
65
  return 0;
66
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.