read_liberty gzip'd files
This commit is contained in:
parent
d2fe0e9497
commit
a202c6bf69
|
|
@ -132,11 +132,9 @@ EOL \r?\n
|
||||||
while (isspace(filename_end[-1]) && filename_end > filename)
|
while (isspace(filename_end[-1]) && filename_end > filename)
|
||||||
filename_end--;
|
filename_end--;
|
||||||
*filename_end = '\0';
|
*filename_end = '\0';
|
||||||
FILE *stream = sta::libertyIncludeBegin(filename);
|
sta::libertyIncludeBegin(filename);
|
||||||
if (stream) {
|
yypush_buffer_state(yy_create_buffer(nullptr, YY_BUF_SIZE));
|
||||||
yypush_buffer_state(yy_create_buffer(stream, YY_BUF_SIZE));
|
BEGIN(INITIAL);
|
||||||
BEGIN(INITIAL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -27,18 +27,18 @@
|
||||||
|
|
||||||
int
|
int
|
||||||
LibertyParse_parse();
|
LibertyParse_parse();
|
||||||
extern FILE *LibertyLex_in;
|
|
||||||
|
|
||||||
namespace sta {
|
namespace sta {
|
||||||
|
|
||||||
typedef Vector<LibertyGroup*> LibertyGroupSeq;
|
typedef Vector<LibertyGroup*> LibertyGroupSeq;
|
||||||
|
|
||||||
static const char *liberty_filename;
|
static const char *liberty_filename;
|
||||||
|
static gzFile liberty_stream;
|
||||||
static int liberty_line;
|
static int liberty_line;
|
||||||
// Previous lex reader state for include files.
|
// Previous lex reader state for include files.
|
||||||
static const char *liberty_filename_prev;
|
static const char *liberty_filename_prev;
|
||||||
static int liberty_line_prev;
|
static int liberty_line_prev;
|
||||||
static FILE *liberty_stream_prev;
|
static gzFile liberty_stream_prev;
|
||||||
|
|
||||||
static LibertyGroupVisitor *liberty_group_visitor;
|
static LibertyGroupVisitor *liberty_group_visitor;
|
||||||
static LibertyGroupSeq liberty_group_stack;
|
static LibertyGroupSeq liberty_group_stack;
|
||||||
|
|
@ -59,8 +59,8 @@ parseLibertyFile(const char *filename,
|
||||||
LibertyGroupVisitor *library_visitor,
|
LibertyGroupVisitor *library_visitor,
|
||||||
Report *report)
|
Report *report)
|
||||||
{
|
{
|
||||||
LibertyLex_in = fopen(filename, "r");
|
liberty_stream = gzopen(filename, "r");
|
||||||
if (LibertyLex_in) {
|
if (liberty_stream) {
|
||||||
liberty_group_visitor = library_visitor;
|
liberty_group_visitor = library_visitor;
|
||||||
liberty_group_stack.clear();
|
liberty_group_stack.clear();
|
||||||
liberty_filename = filename;
|
liberty_filename = filename;
|
||||||
|
|
@ -69,12 +69,36 @@ parseLibertyFile(const char *filename,
|
||||||
liberty_line = 1;
|
liberty_line = 1;
|
||||||
liberty_report = report;
|
liberty_report = report;
|
||||||
LibertyParse_parse();
|
LibertyParse_parse();
|
||||||
fclose(LibertyLex_in);
|
gzclose(liberty_stream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw FileNotReadable(filename);
|
throw FileNotReadable(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
libertyGetChars(char *buf,
|
||||||
|
int &result,
|
||||||
|
size_t max_size)
|
||||||
|
{
|
||||||
|
char *status = gzgets(liberty_stream, buf, max_size);
|
||||||
|
if (status == Z_NULL)
|
||||||
|
result = 0; // YY_nullptr
|
||||||
|
else
|
||||||
|
result = strlen(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
libertyGetChars(char *buf,
|
||||||
|
size_t &result,
|
||||||
|
size_t max_size)
|
||||||
|
{
|
||||||
|
char *status = gzgets(liberty_stream, buf, max_size);
|
||||||
|
if (status == Z_NULL)
|
||||||
|
result = 0; // YY_nullptr
|
||||||
|
else
|
||||||
|
result = strlen(buf);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
libertyGroupBegin(const char *type,
|
libertyGroupBegin(const char *type,
|
||||||
LibertyAttrValueSeq *params,
|
LibertyAttrValueSeq *params,
|
||||||
|
|
@ -510,30 +534,31 @@ libertyInInclude()
|
||||||
return liberty_filename_prev != nullptr;
|
return liberty_filename_prev != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
void
|
||||||
libertyIncludeBegin(const char *filename)
|
libertyIncludeBegin(const char *filename)
|
||||||
{
|
{
|
||||||
FILE *stream = fopen(filename, "r" );
|
gzFile stream = gzopen(filename, "r" );
|
||||||
if (stream) {
|
if (stream) {
|
||||||
|
liberty_stream_prev = liberty_stream;
|
||||||
liberty_filename_prev = liberty_filename;
|
liberty_filename_prev = liberty_filename;
|
||||||
liberty_line_prev = liberty_line;
|
liberty_line_prev = liberty_line;
|
||||||
liberty_stream_prev = LibertyLex_in;
|
|
||||||
|
|
||||||
|
liberty_stream = stream;
|
||||||
liberty_filename = filename;
|
liberty_filename = filename;
|
||||||
liberty_line = 1;
|
liberty_line = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
libertyParseError("cannot open include file %s.", filename);
|
libertyParseError("cannot open include file %s.", filename);
|
||||||
return stream;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
libertyIncludeEnd()
|
libertyIncludeEnd()
|
||||||
{
|
{
|
||||||
fclose(LibertyLex_in);
|
gzclose(liberty_stream);
|
||||||
|
liberty_stream = liberty_stream_prev;
|
||||||
liberty_filename = liberty_filename_prev;
|
liberty_filename = liberty_filename_prev;
|
||||||
liberty_line = liberty_line_prev;
|
liberty_line = liberty_line_prev;
|
||||||
LibertyLex_in = liberty_stream_prev;
|
|
||||||
liberty_filename_prev = nullptr;
|
liberty_filename_prev = nullptr;
|
||||||
liberty_stream_prev = nullptr;
|
liberty_stream_prev = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "DisallowCopyAssign.hh"
|
#include "DisallowCopyAssign.hh"
|
||||||
|
#include "Zlib.hh"
|
||||||
#include "Vector.hh"
|
#include "Vector.hh"
|
||||||
#include "Map.hh"
|
#include "Map.hh"
|
||||||
#include "Set.hh"
|
#include "Set.hh"
|
||||||
|
|
@ -51,6 +52,20 @@ enum class LibertyAttrType { attr_string, attr_int, attr_double,
|
||||||
|
|
||||||
enum class LibertyGroupType { library, cell, pin, timing, unknown };
|
enum class LibertyGroupType { library, cell, pin, timing, unknown };
|
||||||
|
|
||||||
|
// flex YY_INPUT yy_n_chars arg changed definition from int to size_t,
|
||||||
|
// so provide both forms.
|
||||||
|
void
|
||||||
|
libertyGetChars(char *buf,
|
||||||
|
size_t &result,
|
||||||
|
size_t max_size);
|
||||||
|
void
|
||||||
|
libertyGetChars(char *buf,
|
||||||
|
int &result,
|
||||||
|
size_t max_size);
|
||||||
|
|
||||||
|
#define YY_INPUT(buf,result,max_size) \
|
||||||
|
sta::libertyGetChars(buf, result, max_size)
|
||||||
|
|
||||||
// Abstract base class for liberty statements.
|
// Abstract base class for liberty statements.
|
||||||
class LibertyStmt
|
class LibertyStmt
|
||||||
{
|
{
|
||||||
|
|
@ -300,7 +315,7 @@ private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(LibertyGroupVisitor);
|
DISALLOW_COPY_AND_ASSIGN(LibertyGroupVisitor);
|
||||||
};
|
};
|
||||||
|
|
||||||
FILE *
|
void
|
||||||
libertyIncludeBegin(const char *filename);
|
libertyIncludeBegin(const char *filename);
|
||||||
void
|
void
|
||||||
libertyIncludeEnd();
|
libertyIncludeEnd();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue