PIPS
model.c
Go to the documentation of this file.
1 /*
2 
3  $Id: model.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27  /* Code Generation for Distributed Memory Machines
28  *
29  * Reads and prints the target machine description (compatible formats)
30  * Temporary version. A more general machine model should be defined by
31  * Lei for complexity evaluation.
32  *
33  * File: model.c
34  *
35  * PUMA, ESPRIT contract 2701
36  *
37  * Francois Irigoin
38  * 1991
39  */
40 
41 #include <stdio.h>
42 #include <string.h>
43 #include <stdlib.h>
44 
45 #include "genC.h"
46 #include "misc.h"
47 #include "top-level.h" /* ??? */
48 #include "properties.h"
49 
50 void model_fprint(FILE * fd, int pn, int bn, int ls)
51 {
52  fprintf(fd,
53  "Target Machine:\n"
54  "Processor number: %d\n"
55  "Memory bank number: %d\n"
56  "Bank width (i.e. line size): %d\n\n", pn, bn, ls);
57 }
58 
59 void model_fscan(FILE * fd, int * ppn, int * pbn, int * pls)
60 {
61  int i1, i2, i3, i4;
62  i1 = fscanf(fd, "Target Machine:\n");
63  i2 = fscanf(fd, "Processor number: %d\n", ppn);
64  i3 = fscanf(fd, "Memory bank number: %d\n", pbn);
65  i4 = fscanf(fd, "Bank width (i.e. line size): %d\n\n", pls);
66  if(i1!=0 && i2!=1 && i3!=1 && i4!=1) {
67  user_error("model_fscan", "Bad format for machine model\n");
68  }
69 }
70 
71 void get_model(int * ppn, int * pbn, int * pls)
72 {
73  FILE * fd;
74  const char* model_rc = get_string_property("WP65_MODEL_FILE");
75  if ((fd = fopen(model_rc, "r")) == NULL) {
76  fd = fopen_config(model_rc, NULL,NULL);
77  }
78 
79  model_fscan(fd, ppn, pbn, pls);
80 }
char * get_string_property(const char *)
FILE * fopen_config(const char *canonical_name, const char *cproperty, const char *cenv)
Definition: file.c:952
#define user_error(fn,...)
Definition: misc-local.h:265
void model_fscan(FILE *fd, int *ppn, int *pbn, int *pls)
Definition: model.c:59
void get_model(int *ppn, int *pbn, int *pls)
Definition: model.c:71
void model_fprint(FILE *fd, int pn, int bn, int ls)
Code Generation for Distributed Memory Machines.
Definition: model.c:50
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...